Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutter_screenutil 6.0.0-alpha.1 #574

Open
vinhqn opened this issue Jun 27, 2024 · 1 comment
Open

flutter_screenutil 6.0.0-alpha.1 #574

vinhqn opened this issue Jun 27, 2024 · 1 comment

Comments

@vinhqn
Copy link

vinhqn commented Jun 27, 2024

My code:

 return MultiProvider(
        providers: [
          ChangeNotifierProvider(create: (_) => UserProvider()),
          ChangeNotifierProvider(create: (_) => TabProvider()),
          // ChangeNotifierProvider(create: (_) => HomeProvider()),
        ],
        child: ScreenUtil(
            key: screenUtilKey,
            options: const ScreenUtilOptions(
              enable: true,
              designSize: Size(360, 690),
              fontFactorByWidth: 2.0,
              fontFactorByHeight: 1.0,
              flipSizeWhenLandscape: true,
            ),
            child: ChangeNotifierProvider(
                lazy: true,
                create: (context) => ThemeProvider(),
                builder: (context, child) {
                  final themeProvider = Provider.of<ThemeProvider>(context);
                  return KeyboardDismissOnTap(
                    child: MaterialApp(
                      navigatorKey: NavigatorService.navigatorKey,
                      localizationsDelegates: context.localizationDelegates,
                      supportedLocales: context.supportedLocales,
                      debugShowCheckedModeBanner: false,
                      locale: context.locale,
                      title: 'FidoBox',
                      // builder: (context, child) =>
                      //     PersistentKeyboardHeightProvider(child: child!),
                      home: SplashScreen(),
                      themeMode: themeProvider.themeMode,
                      theme: MyTheme().light,
                      darkTheme: MyTheme().dark,
                      onGenerateRoute: (settings) =>
                          NavigatorConfig.onGenerateRoute(settings),
                      initialRoute: NavigatorName.splash,
                    ),
                  );
                })));
                
                ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following _TypeError was thrown building Consumer<TabProvider>(dirty, dependencies:
[_InheritedProviderScope<TabProvider?>]):
Null check operator used on a null value

The relevant error-causing widget was:
  Consumer<TabProvider>
  Consumer:file:///Users/macbook/fidobox/lib/screens/main_tab/main_bottom_bar.dart:232:14

When the exception was thrown, this was the stack:
#0      ScreenUtilSingleton.h (package:flutter_screenutil/src/widgets/screen_util_singleton.dart:44:50)
#1      ScreenUtilSingletonExtension.h (package:flutter_screenutil/src/utils/extensions.dart:27:39)
#2      _MainBottomBar.build.<anonymous closure>.<anonymous closure> (package:fidobox/screens/main_tab/main_bottom_bar.dart:237:46)
#3      Consumer.buildWithChild (package:provider/src/consumer.dart:179:19)
#4      SingleChildStatelessWidget.build (package:nested/nested.dart:259:41)
#5      StatelessElement.build (package:flutter/src/widgets/framework.dart:5557:49)
#6      SingleChildStatelessElement.build (package:nested/nested.dart:279:18)
#7      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5487:15)
#8      Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#9      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:5469:5)
#10     ComponentElement.mount (package:flutter/src/widgets/framework.dart:5463:5)
#11     SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (32 frames)
#43     Element.inflateWidget (package:flutter/src/widgets/framework.dart:4340:16)
#44     MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6904:36)
#45     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6916:32)
...     Normal element mounting (7 frames)
#52     SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (25 frames)
#77     Element.inflateWidget (package:flutter/src/widgets/framework.dart:4340:16)
#78     MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6904:36)
#79     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6916:32)
...     Normal element mounting (340 frames)
#419    Element.inflateWidget (package:flutter/src/widgets/framework.dart:4340:16)
#420    MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6904:36)
#421    Element.updateChild (package:flutter/src/widgets/framework.dart:3849:18)
#422    Element.updateChildren (package:flutter/src/widgets/framework.dart:4036:32)
#423    MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6929:17)
#424    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#425    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5512:16)
#426    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5650:11)
#427    Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#428    StatefulElement.update (package:flutter/src/widgets/framework.dart:5673:5)
#429    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#430    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5512:16)
#431    Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#432    ProxyElement.update (package:flutter/src/widgets/framework.dart:5816:5)
#433    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#434    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5512:16)
#435    Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#436    ProxyElement.update (package:flutter/src/widgets/framework.dart:5816:5)
#437    _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:105:11)
#438    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#439    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5512:16)
#440    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5650:11)
#441    Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#442    StatefulElement.update (package:flutter/src/widgets/framework.dart:5673:5)
#443    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#444    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5512:16)
#445    Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#446    ProxyElement.update (package:flutter/src/widgets/framework.dart:5816:5)
#447    _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:105:11)
#448    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#449    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5512:16)
#450    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5650:11)
#451    Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#452    StatefulElement.update (package:flutter/src/widgets/framework.dart:5673:5)
#453    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#454    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5512:16)
#455    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5650:11)
#456    Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#457    StatefulElement.update (package:flutter/src/widgets/framework.dart:5673:5)
#458    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#459    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6776:14)
#460    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#461    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6776:14)
#462    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#463    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5512:16)
#464    Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#465    ProxyElement.update (package:flutter/src/widgets/framework.dart:5816:5)
#466    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#467    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5512:16)
#468    Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#469    ProxyElement.update (package:flutter/src/widgets/framework.dart:5816:5)
#470    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#471    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5512:16)
#472    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5650:11)
#473    Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#474    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2905:19)
#475    WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1136:21)
#476    RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:443:5)
#477    SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1392:15)
#478    SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1313:9)
#479    SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:1035:9)
#480    PlatformDispatcher.scheduleWarmUpFrame.<anonymous closure> (dart:ui/platform_dispatcher.dart:837:16)
#484    _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
(elided 3 frames from class _Timer and dart:async-patch)

════════════════════════════════════════════════════════════════════════════════════════════════════
@Mounir-Bouaiche
Copy link
Collaborator

Mounir-Bouaiche commented Jun 27, 2024

@vinhqn When using Singleton approach, wrap your tree with ScreenUtilSingleton widget instead of ScreenUtil widget

Ref:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants