Flutter修改AppBar的主题

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo', //应用名
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        scaffoldBackgroundColor: Colors.white, //修改页面的背景
        //修改AppBar的主体样式
        appBarTheme: const AppBarTheme(
          backgroundColor: Colors.white,
          elevation: 0,  //隐藏AppBar底部的阴影分割线
          systemOverlayStyle: SystemUiOverlayStyle.dark //设置状态栏的背景
        ),
        visualDensity: VisualDensity.standard
      ),
      home: const MyHomePage(title: 'Hello Flutter'),
    );
  }
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/xiaopihair123/article/details/125336355