我正在尝试在Flutter中更改整个MaterialApp主题的背景颜色。 ThemeData的scaffoldBackgroundColor有效,但我不能100%确定Flutter中的MaterialApp应该被编码的方式。
@override
class MyApp extends StatelessWidget {
// This widget is the root of your application.
final AllText allText = AllText();
final colorOrange = const Color(0xFFF89921);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
// Tells the system which are the supported languages
supportedLocales: allTranslations.supportedLocales(),
title: allText.foreCanvass,
theme: ThemeData(
scaffoldBackgroundColor: colorOrange,
),
initialRoute: '/',
routes: {
'/': (context) => UserLogin(),
},
);
}
}
你在做什么已经是正确的,你应该尝试完全重启。除非您执行完全重启或热重启,否则主要更改不会更改。