flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.81k stars 27.65k forks source link

Widget recursion does not provide sufficient error information after crashing. #155032

Open Ubuntuify opened 2 months ago

Ubuntuify commented 2 months ago

Steps to reproduce

This issue is platform agnostic.

  1. Create a MaterialApp (other types would most likely work as this seems to be a stack overflow error which simply doesn't get caught by any analysis)
  2. Create a Widget which contains Scaffold with a body of type List<Widget> and open any arbitrary value within the list.
  3. Make sure that List<Widget> contains the class that it is inside.

Expected results

Flutter should throw a clearer error which states that a stack overflow is occuring, or perhaps throw a recursion error.

Actual results

Flutter throws the unclear Failed assertion error. DartPad seems to properly throw and report a stack overflow to the user, however.

Code sample

Code sample ```dart import 'package:flutter/material.dart'; void main() { runApp(const App()); } class App extends StatelessWidget { const App({super.key}); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Home(), ); } } class Home extends StatefulWidget { @override State createState() => _HomeState(); } class _HomeState extends State { int navigationIndex = 0; List navigationPages = [Home()]; @override Widget build(BuildContext build) { return Scaffold( body: navigationPages[navigationIndex], ); } } ```

Screenshots or Video

No response

Logs

Logs [stacktrace.log](https://github.com/user-attachments/files/16967378/stacktrace.log)

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.24.2, on macOS 15.1 24B5035e darwin-arm64, locale en-US) • Flutter version 3.24.2 on channel stable at /Users/ryan/.development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 4cf269e36d (8 days ago), 2024-09-03 14:30:00 -0700 • Engine revision a6bd3f1de1 • Dart version 3.5.2 • DevTools version 2.37.2 [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) • Android SDK at /Users/ryan/Library/Android/sdk • Platform android-35, build-tools 35.0.0 • Java binary at: /Users/ryan/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314) • All Android licenses accepted. [!] Xcode - develop for iOS and macOS (Xcode 16.1) • Xcode at /Applications/Xcode-beta.app/Contents/Developer • Build 16B5001e ✗ CocoaPods not installed. CocoaPods is a package manager for iOS or macOS platform code. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/to/platform-plugins For installation instructions, see https://guides.cocoapods.org/using/getting-started.html#installation [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2024.1) • Android Studio at /Users/ryan/Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314) [✓] IntelliJ IDEA Ultimate Edition (version 2024.2.1) • IntelliJ at /Users/ryan/Applications/IntelliJ IDEA Ultimate.app • Flutter plugin version 81.1.3 • Dart plugin version 242.21829.3 [✓] Connected device (4 available) • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 15 (API 35) (emulator) • macOS (desktop) • macos • darwin-arm64 • macOS 15.1 24B5035e darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.1 24B5035e darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 128.0.6613.137 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 1 category. ```
darshankawar commented 2 months ago

Thanks for the report. Seeing the same behavior as reported. The code purposely throws a repeatative / recursion error, but the stacktrace shows Failed assertion: line.

Stable : 3.24.2
Master: 3.26.0-1.0.pre.72