我正在尝试在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(),
},
);
}
}
答案 0 :(得分:2)
您所做的已经正确,您应该尝试完全重启。除非进行完全重启或热重启,否则main的更改不会更改。