Flutter——Widget(5)、Button
RaisedButton Material Design中的button, 一个凸起的材质矩形按钮。
-
onPressed 点击事件。 textColor 按钮可用时的文字颜色,尽量不要在child中指定,否则disabledTextColor会不生效。 disabledTextColor 按钮不可用时(onPressed: null)的文字颜色。 color 按钮的颜色。 disabledColor 按钮被禁用的时候显示的颜色。 highlightColor 点击或者touch控件高亮时的颜色。 splashColor 点击时在按钮颜色上显示水波纹的颜色。 elevation 按钮下面的阴影。 child 子控件,常用的是设置显示的Text控件文本。
实现代码如下:
import package:flutter/material.dart;
import package:flutter_demo/Login.dart;
/// 2019/6/5 created by JasonZhang
/// 类注释:
class PageThree extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "我的信息",
theme: ThemeData(primarySwatch: Colors.blue),
home: Scaffold(
appBar: AppBar(title: Text("我的信息")),
body: Center(
child: RaisedButton(
// 按钮可用时的文字颜色,不要在child中指定,否则disabledTextColor会不生效
textColor: Colors.white,
// 按钮不可用时(onPressed: null)的文字颜色,
disabledTextColor: Colors.white30,
// 点击事件
onPressed: () {
//跳转到新的页面调用 navigator.push方法
Navigator.push(context,
new MaterialPageRoute(builder: (context) => new Login()));
},
// onPressed: null,
//按钮的背景颜色
color: Colors.blue,
//按钮被禁用的时候显示的颜色
// disabledColor: Colors.red,
//点击或者touch控件高亮时的颜色
// highlightColor: Colors.red,
//点击时在按钮颜色上显示水波纹的颜色
splashColor: Colors.blueAccent,
//按钮下面的阴影
elevation: 5,
child: new Text("登录"),
),
)),
);
}
}
上一篇:
IDEA上Java项目控制台中文乱码
