Skip to content

The Flutter DevTools break my app in debug builds #908

@rekire

Description

@rekire

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.

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

StackTrace
Here is the StackTrace I got in my App:

#0      throwIfNot (package:get_it/get_it_impl.dart:14:19)
#1      _GetItImplementation._findFactoryByNameAndType (package:get_it/get_it_impl.dart:578:5)
#2      _GetItImplementation.get (package:get_it/get_it_impl.dart:602:29)
#3      _GetItImplementation.call (package:get_it/get_it_impl.dart:675:12)
#4      AppProviders.build.<anonymous closure> (package:censored/src/app_providers.dart:85:33)
#5      _CreateInheritedProviderState.value (package:provider/src/inherited_provider.dart:736:36)
#6      ProviderNode.value (package:provider/src/devtool.dart:71:48)
#7      Eval ()

This causes also a bug in Flutter see: flutter/flutter#166572

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions