【发布时间】:2018-10-18 21:57:49
【问题描述】:
我有一个材质应用程序,它使用基于浅色主题的主题。我正在将scaffoldBackgroundColor 更改为似乎不需要的特定颜色。页面的背景是黑色而不是灰色。
应用程序的build() 方法将这个应用程序标识为MaterialApp:
Widget build(BuildContext context) {
return new MaterialApp(
title: '???',
theme: appTheme,
routes: {
AppRoutes.login: (context) {
return new LoginPage(
authenticator: authenticate,
);
},
AppRoutes.home: (context) {
return new HomePage(
appState: appState,
accountRepository: widget.accountRepository,
authRepository: widget.authRepository,
);
},
},
);
}
主题 - 在这里我重用浅色主题作为我的新主题的基础,将脚手架背景颜色更改为自定义颜色:
const coolGreyHi = const Color.fromARGB(40,30,20,66);
final ThemeData appTheme = _buildAppTheme();
ThemeData _buildAppTheme() {
final ThemeData base = new ThemeData.light();
return base.copyWith(
scaffoldBackgroundColor: coolGreyHi,
inputDecorationTheme: new InputDecorationTheme(
border: new OutlineInputBorder(),
)
);
}
背景为灰色的页面的构建方法:
Widget build(BuildContext context) {
return new Scaffold(
body: new SafeArea(
child: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new Padding(
padding: const EdgeInsets.fromLTRB(40.0, 0.0, 40.0, 0.0),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new Image.asset('images/image.png'),
new SizedBox(height: 40.0),
new TextField(
controller: _uidTextController, decoration: new InputDecoration(
hintText: "you@yourdomain.com",
labelText: "Email Address",
),
),
new SizedBox(height: 12.0),
new TextField(
controller: _pwdTextController, decoration: new InputDecoration(
hintText: "Password",
labelText: "Password",
),
),
new SizedBox(height: 12.0),
new ButtonBar(
children: <Widget>[
new FlatButton(
child: new Text("SIGN UP"),
onPressed: () {},
),
new RaisedButton(
child: new Text("SIGN IN"),
elevation: 8.0,
onPressed: () {
authenticator(_uidTextController.text, _pwdTextController.text).then((bool isAuthenticated) {
if (isAuthenticated)
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.home, (Route<dynamic> route) => false);
});
},
),
],
),
],
),
),
],
),
),
),
);
}
【问题讨论】:
-
这个问题可以按照文档说明解决
-
@DiegoMarquina,我以为我是,但我没有得到想要的结果。除非我遗漏了什么,否则您提到的文档 sn-ps 我还没有看到,或者这是另一种情况。您指的是哪些特定的 sn-ps 文档?
标签: dart flutter flutter-layout