main function the main problem the condition in ThemeMode isn't execute except true
Widget build(BuildContext context) {
return BlocProvider(
create: (context)=>AppCubit(),
child: BlocConsumer<AppCubit,Appstates>(
listener: (BuildContext context,state){
if(state is AppGetMode)
{
print(AppCubit.get(context).isDark);
}
},
builder: (context,state) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme:ThemeData(
primarySwatch: Colors.deepOrange,
scaffoldBackgroundColor: Colors.white,
appBarTheme: AppBarTheme(
titleSpacing: 20.0,
backwardsCompatibility: false,
backgroundColor: Colors.white,
elevation: 0.0,
titleTextStyle: TextStyle(
color: Colors.black,
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
darkTheme:ThemeData(
primarySwatch: Colors.deepOrange,
scaffoldBackgroundColor: Colors.grey,
appBarTheme: AppBarTheme(
titleSpacing: 20.0,
elevation: 0.0,
titleTextStyle: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
iconTheme: IconThemeData(
color: Colors.white,
),
),
floatingActionButtonTheme: FloatingActionButtonThemeData(
backgroundColor: Colors.deepOrange,
),
),
),
themeMode:AppCubit.get(context).isDark ? ThemeMode.dark:ThemeMode.light,
home: Navigation(),
);
},
),
);
}
The error in ThemeMode it's Not change when i press on Icon Button and the Theme is always light AppCubit Function to change mode by bool true is Dark false is Light The blocConsume an BlocProvider is running in more than screen
iconButton with onpressed
Padding(
padding: EdgeInsets.all(8.0),
child: IconButton(onPressed: () {AppCubit.get(context).modeAppNews();}, icon: const Icon(Icons.dark_mode_outlined) )
)