flutter 整体样式设置

时间:2020-10-02

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

设置亮色主题

brightness: Brightness.light,

设置appbar没有边框

elevation: 0,

设置appbar文字居中

centerTitle: true,

设置返回键白色

iconTheme: IconThemeData(
  color: Colors.white,
),

设置app界面背景颜色

scaffoldBackgroundColor: Color.fromARGB(255, 245, 246, 250),