BirjuVachhani / adaptive_theme

Easiest way to add support for light and dark theme in your flutter app.
https://pub.dev/packages/adaptive_theme
Apache License 2.0
464 stars 37 forks source link

addListener() - Null check operator used on a null value #33

Closed Arfmann21 closed 2 years ago

Arfmann21 commented 2 years ago

As title, using

 AdaptiveTheme.of(context).modeChangeNotifier.addListener(() {
        // set status bar here.
        });

gives the error "Null check operator used on a null value".

I've tried putting in inside initState and AdaptiveTheme builder, none of it worked.

In documentation, there aren't any info on where to put this method.

BirjuVachhani commented 2 years ago

@Arfmann21 Can you please share the stacktrace and the code where you put this listener?

BirjuVachhani commented 2 years ago

@Arfmann21 The reason it is not mentioned in the docs where to put it, is that it depends on the usecase. What's your usecase?

FYI: You should not put it anywhere before MaterialApp widget. Certainly not in the AdaptiveTheme builder.