This issue happens when returning Theme in MaterialApp.router. I think it has something to do with the child property. When I replace the child with a floating widget for example, the red screen and error goes away
The following StateError was thrown building IconTheme(color: Color(0xdd000000)): Bad state : No element
code:
class NnsDapp extends StatelessWidget {
final HiveBoxes hiveBoxes;
final WalletRouterDelegate router;
const NnsDapp({Key? key, required this.hiveBoxes, required this.router})
: super(key: key);
@override
Widget build(BuildContext context) {
return HiveBoxesWidget(
boxes: hiveBoxes,
child: ICApiManager(
child: Builder(builder: (context) {
return MaterialApp.router(
builder: (context, child) {
return Theme(
data: getTheme(Responsive.isMobile(context)), child: child!);
},
debugShowCheckedModeBanner: false,
routerDelegate: router,
routeInformationParser: WalletRouteParser(hiveBoxes, context),
title: 'Network Nervous System',
);
}),
),
);
}
ThemeData getTheme(bool isMobile) {
return ThemeData(
primarySwatch: MaterialColor(AppColors.blue500.value, {
1000: AppColors.blue1000,
900: AppColors.blue900,
}),
textTheme: nnsDappTextTheme(isMobile),
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
textStyle:
MaterialStateProperty.all(TextStyle(color: Colors.white)),
overlayColor: MaterialStateProperty.all(
AppColors.gray400.withOpacity(0.04)))),
);
}
}
TextTheme nnsDappTextTheme(bool isMobile) {
return TextTheme(
headline1: TextStyle(
fontSize: isMobile ? 32 : 40,
fontFamily: Fonts.circularBold,
color: AppColors.gray50,
fontWeight: FontWeight.w700),)
}