屏幕快照 2019-02-14 下午6.23.44.png
代碼
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("搜索記錄"),
),
body: Wrap(
spacing: 8.0,// 橫向間距
runSpacing: -2.0,//縱向間距
children: <Widget>[
Chip(
avatar: new CircleAvatar(
backgroundColor: Colors.blue,
child: Text('M'),
),
label: new Text('Mulligansadfsadgasd'),
),
Chip(
avatar: new CircleAvatar(
backgroundColor: Colors.blue,
child: Text('M'),
),
label: new Text('Mulligansaadsgasdgdfsadgasd'),
),
Chip(
avatar: new CircleAvatar(
backgroundColor: Colors.blue,
child: Text('M'),
),
label: new Text('Mdgasd'),
),
Chip(
avatar: new CircleAvatar(
backgroundColor: Colors.blue,
child: Text('M'),
),
label: new Text('Mgasd'),
),
Chip(
avatar: new CircleAvatar(
backgroundColor: Colors.blue,
child: Text('M'),
),
label: new Text('Mullfsadgasd'),
)
],
)
);
}
}
- Wrap
spacing:橫軸方向子widget的間距
alignment: 橫軸對(duì)其方式
runSpacing:縱軸方向的間距
runAlignment:縱軸方向的對(duì)齊方式
Wrap({
Key key,
this.direction = Axis.horizontal,
this.alignment = WrapAlignment.start,
this.spacing = 0.0,
this.runAlignment = WrapAlignment.start,
this.runSpacing = 0.0,
this.crossAxisAlignment = WrapCrossAlignment.start,
this.textDirection,
this.verticalDirection = VerticalDirection.down,
List<Widget> children = const <Widget>[],
}) : super(key: key, children: children);
- Chip
Chip({
Key key,
this.avatar,//標(biāo)簽左側(cè)Widget,一般為小圖標(biāo)
@required this.label,//標(biāo)簽
this.labelStyle,
this.labelPadding,//padding
this.deleteIcon//刪除圖標(biāo),
this.onDeleted//刪除回調(diào)报亩,為空時(shí)不顯示刪除圖標(biāo),
this.deleteIconColor//刪除圖標(biāo)的顏色,
this.deleteButtonTooltipMessage//刪除按鈕的tip文字,
this.shape//形狀,
this.clipBehavior = Clip.none,
this.backgroundColor//背景顏色,
this.padding,
this.materialTapTargetSize//刪除圖標(biāo)material點(diǎn)擊區(qū)域大小,
})