flutter-intellij icon indicating copy to clipboard operation
flutter-intellij copied to clipboard

The Flutter DevTools break my app in debug builds

Open rekire opened this issue 8 months ago • 2 comments

Describe the bug I have an app with a complex initialization which takes around 5 seconds. I am registration a couple of singeltons in getIt. Since the Android Studio plugin pulls the data too early everything breaks for me.

To Reproduce

MultiProvider(
  providers: [
    ChangeNotifierProvider<Example>(
      // normally this method gets invoked after App() is created
      create: (_) => getIt<Example>(), // this crashes and causes also a bug in flutter #166572
    ),
  ],
  child: FutureBuilder(
    future: longRunningInitFuture(),
    builder: (context, snapshot) {
      if (snapshot.connectionState == ConnectionState.done && snapshot.data == true) {
        return const App();
      } else {
        return const SplashScreen();
      }
    },
  ),
)

When I try to consume the Example class like this:

Consumer<Example>(
  builder: (context, example, _) {
    // never called
  }
)

Then I get strange exceptions within the widget tree. See the https://github.com/flutter/flutter/issues/166572 for details.

Expected behavior I do not expect that the Flutter DevTools Extension collects the data without any interaction from me.

Known workarounds Disable the extension and enable it only when required after start of the app

Related bugs: https://github.com/flutter/flutter/issues/166572, https://github.com/rrousselGit/provider/issues/908

rekire avatar Apr 04 '25 09:04 rekire

/fyi @elliette

pq avatar Apr 09 '25 21:04 pq

/fyi @helin24

pq avatar Jun 12 '25 03:06 pq