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

The getter 'length' was called on null. #1

Closed
mjhansen3 opened this issue Jul 5, 2019 · 1 comment
Closed

The getter 'length' was called on null. #1

mjhansen3 opened this issue Jul 5, 2019 · 1 comment

Comments

@mjhansen3
Copy link

mjhansen3 commented Jul 5, 2019

I followed the documentation but I seem to be getting this issue.

I/flutter (26830): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (26830): The following NoSuchMethodError was thrown building UHungry(dirty):
I/flutter (26830): The getter 'length' was called on null.
I/flutter (26830): Receiver: null
I/flutter (26830): Tried calling: length
I/flutter (26830): 
I/flutter (26830): When the exception was thrown, this was the stack:
I/flutter (26830): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
I/flutter (26830): #1      new AppTheme (package:theme_provider/src/data/app_theme.dart:84:24)
I/flutter (26830): #2      defaultMode (package:uHungry/main.dart:65:12)
I/flutter (26830): #3      UHungry.build (package:uHungry/main.dart:258:29)
I/flutter (26830): #4      StatelessElement.build (package:flutter/src/widgets/framework.dart:3886:28)
I/flutter (26830): #5      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3836:15)
I/flutter (26830): #6      Element.rebuild (package:flutter/src/widgets/framework.dart:3657:5)
I/flutter (26830): #7      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3819:5)
I/flutter (26830): #8      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3814:5)
I/flutter (26830): #9      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3053:14)
I/flutter (26830): #10     Element.updateChild (package:flutter/src/widgets/framework.dart:2856:12)
I/flutter (26830): #11     RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:939:16)
I/flutter (26830): #12     RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:910:5)
I/flutter (26830): #13     RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:856:17)
I/flutter (26830): #14     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2295:19)
I/flutter (26830): #15     RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:855:13)
I/flutter (26830): #16     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:736:7)
I/flutter (26830): #17     runApp (package:flutter/src/widgets/binding.dart:786:7)
I/flutter (26830): #18     main.<anonymous closure> (package:uHungry/main.dart:58:9)
I/flutter (26830): #28     SystemChrome.setPreferredOrientations (package:flutter/src/services/system_chrome.dart)
I/flutter (26830): #39     OptionalMethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart)
I/flutter (26830): #50     MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart)
I/flutter (26830): (elided 43 frames from package dart:async and package dart:async-patch)
I/flutter (26830): ════════════════════════════════════════════════════════════════════════════════════════════════════

This occurs when I try to use my own custom AppTheme

AppTheme(
      id: "dark_mode",
      data: ThemeData(
          appBarTheme: AppBarTheme(
            color: Color(0xFF1E1E1E),
            elevation: 1.5,
          ),
          scaffoldBackgroundColor: Color(0xFF121212),
          backgroundColor: Color(0xFF1E1E1E),
          dialogBackgroundColor: Color(0xFF121212),
          bottomSheetTheme: BottomSheetThemeData(
              backgroundColor: Color(0xFF121212),
              elevation: 0,
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(40),
                    topRight: Radius.circular(40),
                  )
              )
          ),
          textTheme: TextTheme(
            body1: TextStyle(
                color: Color(0xFFFFFFFF)
            ),
            body2: TextStyle(
                color: Color(0xFF8A8A8A)
            ),
            title: TextStyle(
                color: Color(0xFFFFFFFF)
            ),
            subtitle: TextStyle(
                color: Color(0xFF8A8A8A)
            ),
            caption: TextStyle(
                color: Color(0xFF8A8A8A)
            ),
            display1: TextStyle(
                color: Color(0xFFF05A22)
            ),
            display2: TextStyle(
                color: Color(0xFFFFFFFF)
            ),
            display3: TextStyle(
                color: Color(0xFF1E1E1E)
            ),
          ),
          cardColor: Color(0xFF1E1E1E),
          splashColor: Colors.transparent,
          highlightColor: Colors.transparent,
          inputDecorationTheme: InputDecorationTheme(
              filled: true,
              fillColor: Colors.transparent,
              enabledBorder: OutlineInputBorder(
                  borderSide: BorderSide(
                      color: Color(0xFF8A8A8A)
                  ),
                  borderRadius: BorderRadius.circular(30.0)
              ),
              focusedBorder: OutlineInputBorder(
                borderSide: BorderSide(
                    color: Color(0xFFF05A22)
                ),
                borderRadius: BorderRadius.circular(30.0),
              ),
              errorBorder: OutlineInputBorder(
                  borderSide: BorderSide(
                      color: Color(0xFFCE020D)
                  ),
                  borderRadius: BorderRadius.circular(30.0)
              ),
              focusedErrorBorder: OutlineInputBorder(
                  borderSide: BorderSide(
                      color: Color(0xFFCE020D)
                  ),
                  borderRadius: BorderRadius.circular(30.0)
              )
          )
      )
  )
@mjhansen3
Copy link
Author

I was able to resolve it. Apparently, the issue occurred because I did not include the description property to my custom AppTheme. I don't understand why that should have happened, which is not required but including it fixed the issue for me.

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

1 participant