flutter 修改界面背景颜色

时间:2020-10-02

参考代码

@override
Widget build(BuildContext context) {
  return MaterialApp(
    title: _title,
    theme: ThemeData(
      brightness: Brightness.light,
      primaryColor: Color.fromARGB(255, 85, 132, 250),
      accentColor: Color.fromARGB(255, 85, 132, 250),
      appBarTheme: AppBarTheme(
        textTheme: TextTheme(
          headline6: TextStyle(fontSize: 16.0, fontStyle: FontStyle.normal),
        ),
        elevation: 0,
      ),
      scaffoldBackgroundColor: Color.fromARGB(255, 245, 246, 250),
    ),
    home: MyStatefulWidget(),
  );
}

这个属性的使用:scaffoldBackgroundColor: Color.fromARGB(255, 245, 246, 250),

设置这个属性后,状态栏的颜色也会更改!