title: Flutter 2 - Dark theme state
body: <p>I'm new with Flutter and I'm building my first Flutter 2 project from scratch.</p>
  <p>I'm having an issue with -&gt;
  <code>themeMode: (state is ChangeThemeSuccess) ? (state.isDarkMode) ? ThemeMode.dark : ThemeMode.light : ThemeMode.light,</code></p>
  <p>It says that <code>(state.isDarkMode)</code> is not recognized</p>
  <p>How can I fix this ?</p>
  <p>Thank you</p>
  <p>main.dart</p>
  <pre><code>class MyApp extends StatelessWidget {
     const MyApp({Key? key}) : super(key: key);
     // This widget is the root of your application.
     @override
     Widget build(BuildContext context) {
     // Initialize all bloc provider used on this entire application here
     return MultiBlocProvider(
        providers: [
           // this bloc used for feature - change language
           BlocProvider&lt;LanguageCubit&gt;(
              create: (BuildContext context) =&gt; LanguageCubit(),
           ),
           // this bloc used to change theme on feature list
           BlocProvider&lt;ThemeCubit&gt;(
              create: (BuildContext context) =&gt; ThemeCubit(),
           ),
       ],
       
       child: InitialLanguage(
          child: BlocBuilder&lt;LanguageCubit, LanguageState&gt;(
             builder: (context, state) {
                return MaterialApp(
                   debugShowCheckedModeBanner: true,
                   scrollBehavior: CustomScrollBehavior(),
                   title: appName,
                   theme: ThemeData.light(),
                   darkTheme: ThemeData.dark(),
                   themeMode: (state is ChangeThemeSuccess)
                      ? (state.isDarkMode)
                      ? ThemeMode.dark
                      : ThemeMode.light
                      : ThemeMode.light,
            
               // below is used for language feature
               supportedLocales: const [
                  Locale('en', 'US'),
                  Locale('sv', 'SE'),
               ],
               
               localizationsDelegates: const [
                  AppLocalizationsDelegate(),
                  GlobalMaterialLocalizations.delegate,
                  GlobalWidgetsLocalizations.delegate,
               ],
               // Returns a locale which will be used by the app
               locale: (state is ChangeLanguageSuccess)
                   ? state.locale
                   : const Locale('en', 'US'),
               home: const Navigation(),
          );
        },
      ),
    ),
  );}}
  </code></pre>
  <p>theme_state.dart</p>
  <pre><code>@immutable
  abstract class ThemeState {}
  
  class ThemeInitial extends ThemeState {}
  
  class ChangeThemeSuccess extends ThemeState {
     final bool isDarkMode;
     ChangeThemeSuccess(this.isDarkMode);
  }
  </code></pre>