使 appbar 与 body 颜色相同
make appbar the same color of the body
我需要使用 AppBar
的 属性,但我需要应用栏与主体颜色相同。好像没有appbar。我对 body 和 appBar 使用了相同的颜色,但 appBar 的颜色更深!
Material 应用代码:
class MyApp extends StatelessWidget {
const MyApp();
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'AppName',
theme: ThemeData(
backgroundColor: Color(pagesBackgroundColor),
appBarTheme: AppBarTheme(
color: Color(pagesBackgroundColor),
),
),
home: const HomePage(),
);
}
}
首页代码:
class HomePage extends StatelessWidget {
const HomePage();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Color(pagesBackgroundColor),
title: Text(
"What's up!",
style: TextStyle(color: Colors.black),
),
elevation: 0.0,
),
body: Column(),
);
}
}
将应用栏颜色设置为透明:
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
title: Text(
"What's up!",
style: TextStyle(color: Colors.black),
),
elevation: 0.0,
),
body: Column(),
);
我需要使用 AppBar
的 属性,但我需要应用栏与主体颜色相同。好像没有appbar。我对 body 和 appBar 使用了相同的颜色,但 appBar 的颜色更深!
Material 应用代码:
class MyApp extends StatelessWidget {
const MyApp();
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'AppName',
theme: ThemeData(
backgroundColor: Color(pagesBackgroundColor),
appBarTheme: AppBarTheme(
color: Color(pagesBackgroundColor),
),
),
home: const HomePage(),
);
}
}
首页代码:
class HomePage extends StatelessWidget {
const HomePage();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Color(pagesBackgroundColor),
title: Text(
"What's up!",
style: TextStyle(color: Colors.black),
),
elevation: 0.0,
),
body: Column(),
);
}
}
将应用栏颜色设置为透明:
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
title: Text(
"What's up!",
style: TextStyle(color: Colors.black),
),
elevation: 0.0,
),
body: Column(),
);