Flutter 颤振背景颜色不变
我是个新手,我需要你的帮助来解决第一个问题 这是main.dart文件:Flutter 颤振背景颜色不变,flutter,Flutter,我是个新手,我需要你的帮助来解决第一个问题 这是main.dart文件: import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context)
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
backgroundColor: Colors.white,
),
home: MyHomePage(title: 'Flutter Login'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
TextStyle style = TextStyle(fontFamily: 'Montserrat', fontSize: 20.0);
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
final emailField = TextField(
obscureText: true,
style: style,
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
hintText: "Email",
border:
OutlineInputBorder(borderRadius: BorderRadius.circular(32.0))),
);
final passwordField = TextField(
obscureText: true,
style: style,
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
hintText: "Contraseña",
border:
OutlineInputBorder(borderRadius: BorderRadius.circular(32.0))),
);
final loginButon = Material(
elevation: 5.0,
borderRadius: BorderRadius.circular(30.0),
color: Color(0xff01A0C7),
child: MaterialButton(
minWidth: MediaQuery.of(context).size.width,
padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
onPressed: () {},
child: Text("Entrar",
textAlign: TextAlign.center,
style: style.copyWith(
color: Colors.white, fontWeight: FontWeight.bold)),
),
);
return Scaffold(
body: SingleChildScrollView(
child: Center(
child: Container(
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(66.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 185.0,
child: Image.asset(
"assets/logo_capenergy.png",
fit: BoxFit.contain,
),
),
SizedBox(height: 45.0),
emailField,
SizedBox(height: 25.0),
passwordField,
SizedBox(
height: 35.0,
),
loginButon,
SizedBox(
height: 15.0,
),
],
),
),
),
),
)
);
}
}
导入“包装:颤振/材料.省道”;
void main()=>runApp(MyApp());
类MyApp扩展了无状态小部件{
//此小部件是应用程序的根。
@凌驾
小部件构建(构建上下文){
返回材料PP(
debugShowCheckedModeBanner:false,
标题:“颤振演示”,
主题:主题数据(
背景颜色:Colors.white,
),
主页:我的主页(标题:“颤振登录”),
);
}
}
类MyHomePage扩展StatefulWidget{
MyHomePage({Key,this.title}):超级(Key:Key);
//此小部件是应用程序的主页。它是有状态的,表示
//它有一个状态对象(定义如下),其中包含影响
//看起来怎么样。
//此类是状态的配置。它保存值(在此
//案例名称)由家长(在本例中为应用程序小部件)提供,以及
//由State的build方法使用。小部件子类中的字段包括
//始终标记为“最终”。
最后的字符串标题;
@凌驾
_MyHomePageState createState()=>\u MyHomePageState();
}
类_MyHomePageState扩展状态{
TextStyle=TextStyle(fontFamily:'Montserrat',fontSize:20.0);
@凌驾
小部件构建(构建上下文){
//每次调用setState时都会重新运行此方法,例如,按done
//通过上面的_incrementCounter方法。
//
//对颤振框架进行了优化,以制定重新运行的构建方法
//快速,这样你就可以重建任何需要更新的东西
//而不是必须单独更改小部件的实例。
最终emailField=TextField(
蒙昧文字:对,
风格:风格,
装饰:输入装饰(
内容填充:来自LTRB(20.0,15.0,20.0,15.0)的EdgeInsets,
hintText:“电子邮件”,
边界:
OutlineInputBorder(borderRadius:borderRadius.circular(32.0)),
);
最终密码字段=文本字段(
蒙昧文字:对,
风格:风格,
装饰:输入装饰(
内容填充:来自LTRB(20.0,15.0,20.0,15.0)的EdgeInsets,
hintText:“Contraseña”,
边界:
OutlineInputBorder(borderRadius:borderRadius.circular(32.0)),
);
最终登录按钮=物料(
标高:5.0,
边界半径:边界半径。圆形(30.0),
颜色:颜色(0xff01A0C7),
子:材质按钮(
minWidth:MediaQuery.of(context).size.width,
填充:来自LTRB(20.0,15.0,20.0,15.0)的边缘设置,
按下:(){},
子:文本(“entra”,
textAlign:textAlign.center,
style:style.copyWith(
颜色:Colors.white,fontwweight:fontwweight.bold),
),
);
返回脚手架(
正文:SingleChildScrollView(
儿童:中心(
子:容器(
颜色:颜色,白色,
孩子:填充(
填充:常数边集全部(66.0),
子:列(
crossAxisAlignment:crossAxisAlignment.center,
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
大小盒子(
身高:185.0,
子:Image.asset(
“assets/logo_capenergy.png”,
适合:BoxFit.contain,
),
),
尺寸箱(高度:45.0),
emailField,
尺寸箱(高度:25.0),
密码字段,
大小盒子(
身高:35.0,
),
罗金布顿,
大小盒子(
身高:15.0,
),
],
),
),
),
),
)
);
}
}
这是颤振应用程序的屏幕截图:
我无法移除或隐藏底部背景较暗的区域。不要将颜色放在容器中,而是放在脚手架中:
Scaffold(
backgroundColor: Colors.white
...
将
SingleChildScrollView
包装成一个扩展小部件
,让我们看看