Text('文本显示')
RichText(
text: TextSpan(style: TextStyle(fontSize: 18), children: [
TextSpan(text: "红色", style: TextStyle(color: Colors.red)),
TextSpan(
text: "加粗",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
TextSpan(
text: "字号+",
style: TextStyle(color: Colors.black, fontSize: 25.0),
),
TextSpan(
text: "字号-",
style: TextStyle(color: Colors.black, fontSize: 12.0),
),
]),
textDirection: TextDirection.ltr,
)
TextField()
TextField(obscureText: true)
new MaterialButton(
color: Colors.blue,
textColor: Colors.white,
child: new Text('MaterialButton'),
onPressed: () {},
)
new FlatButton(
child: new Text('FlatButton'),
onPressed: () {},
)
new RaisedButton(
child: new Text('RaisedButton'),
onPressed: () {},
)
new OutlineButton(
borderSide: new BorderSide(color: Theme.of(context).primaryColor),
child: new Text(
'线框按钮',
),
onPressed: () {},
)
new IconButton(
icon: new Icon(Icons.add_circle),
onPressed: () {},
)
new IconButton(
icon: ImageIcon(AssetImage("images/test.png")),
onPressed: () {},
)
PS:
从本地目录加载时,需要先将图片放到本地指定目录,并修改pubspec.yaml添加图片目录.
new FloatingActionButton(
child: new Icon(Icons.add_a_photo),
onPressed: () {},
),
Switch(
activeColor: Colors.white,
activeTrackColor: Colors.green,
inactiveThumbColor: Colors.white,
inactiveTrackColor: Colors.grey,
value: true,
onChanged: (bool v) {},
)
new CupertinoSwitch(
value: true,
onChanged: (bool value) {},
)
new SwitchListTile(
secondary: const Icon(Icons.airplanemode_active),
title: const Text('带标题开关'),
value: this.isSwitchSelected,
onChanged: (bool value) {
setState(() {
this.isSwitchSelected = value;
});
},
)
new Radio(
groupValue: this.radioValue,
activeColor: Colors.blue,
value: '用户选择值',
onChanged: (String val) {
this.setState(() {
this.radioValue = val;
});
},
)
Row(
children: [
Radio(
value: "单选框值1",
groupValue: radioValue,
onChanged: (val) {
setState(() {
radioValue = val;
});
}),
Radio(
value: "单选框值2",
groupValue: radioValue,
onChanged: (val) {
setState(() {
radioValue = val;
});
}),
],
)
Column(
children: [
RadioListTile(
value: 0,
groupValue: radioListValue,
onChanged: (value) {
setState(() {
radioListValue = value;
});
},
title: Text('单选框值1'),
subtitle: Text('描述1'),
secondary: Icon(Icons.filter_1),
//右侧图标
selected: radioListValue == 0,
),
RadioListTile(
value: 1,
groupValue: radioListValue,
onChanged: (value) {
setState(() {
radioListValue = value;
});
},
title: Text('单选框值2'),
subtitle: Text('描述2'),
secondary: Icon(Icons.filter_2),
//右侧图标
selected: radioListValue == 0,
),
],
)
new Checkbox(
value: this.isChecked,
activeColor: Colors.blue,
onChanged: (bool val) {
setState(() {
this.isChecked = val;
});
},
)
CheckboxListTile(
secondary: const Icon(Icons.airplanemode_active),
title: const Text('带标题复选框'),
value: isChecked,
onChanged: (bool value) {
setState(() {
isChecked = value;
});
},
)
new Image.asset("images/test.png")
PS:
从本地目录加载时,需要先将图片放到本地指定目录,并修改pubspec.yaml添加图片目录.
Image.network('https://upload-images.jianshu.io/upload_images/6169789-91306f8ca35b8fe2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240')
new DropdownButton(
onChanged: (String newValue) {},
items: ['Menu1', 'Menu2', 'Menu3', 'Menu4']
.map>((String value) {
return DropdownMenuItem(
value: value,
child: Text(value),
);
}).toList(),
)