-
Notifications
You must be signed in to change notification settings - Fork 188
/
wrap_page.dart
38 lines (34 loc) · 958 Bytes
/
wrap_page.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import 'package:flutter/material.dart';
class WrapPage extends StatefulWidget {
@override
_WrapPageState createState() => _WrapPageState();
}
class _WrapPageState extends State<WrapPage> {
final List<String> _list = List<String>.generate(10, (i) => 'chip$i');
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('WrapPage'),
),
body: Wrap(
spacing: 10,
runSpacing: 5,
children: _list.map<Widget>((s) {
return Chip(
label: Text('$s'),
avatar: Icon(Icons.person),
deleteIcon: Icon(
Icons.close,
color: Colors.red,
),
onDeleted: () {
setState(() {
_list.remove(s);
});
},
);
}).toList()
));
}
}