-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.dart
128 lines (119 loc) · 3.19 KB
/
main.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import 'package:flutter/material.dart';
import 'package:path_icon/path_icon.dart';
import 'icons.dart';
void main() {
runApp(ExampleApp());
}
class ExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Path icon demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({
Key? key,
}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
Color _color = Colors.black;
double _size = 24;
Duration _duration = Duration(seconds: 1);
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: SafeArea(
child: Column(
children: [
Picker<Color>(
values: {
Colors.black: 'black',
Colors.red: 'red',
Colors.pink: 'pink',
Colors.teal: 'teal',
},
value: _color,
onSelected: (v) => setState(() => _color = v),
),
Picker<double>(
values: {
12: 'small',
24: 'medium',
64: 'big',
},
value: _size,
onSelected: (v) => setState(() => _size = v),
),
Expanded(
child: ListView(
children: [
...icons.map(
(x) => Row(
children: [
Container(
margin: const EdgeInsets.all(10),
color: const Color(0xFFEEEEEE),
child: PathIcon(
x,
color: _color,
size: _size,
),
),
SizedBox(width: 20),
Container(
margin: const EdgeInsets.all(10),
color: const Color(0xFFEEEEEE),
child: AnimatedPathIcon(
x,
duration: _duration,
color: _color,
size: _size,
),
),
],
),
),
],
),
),
],
),
),
);
}
}
class Picker<T> extends StatelessWidget {
const Picker({
Key? key,
required this.value,
required this.onSelected,
required this.values,
}) : super(key: key);
final Map<T, String> values;
final ValueChanged<T> onSelected;
final T value;
@override
Widget build(BuildContext context) {
final entries = values.entries.toList()
..sort((x, y) => x.value.compareTo(x.value));
return Wrap(
children: [
...entries.map(
(x) => RaisedButton(
onPressed: () => onSelected(x.key),
child: Text(x.value),
),
),
],
);
}
}