-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathsliver_selector.dart
71 lines (65 loc) · 1.5 KB
/
sliver_selector.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
///
/// Created by NieBin on 18-12-5
/// Github: https://github.com/nb312
/// Email: niebin312@gmail.com
///
import "package:flutter/material.dart";
import 'view_selector.dart';
const _SLIVER_TITLE = "sliver type";
const _SLIVER_VALUES = [
"SliverGrid",
"SliverFixedExtentList",
"SliverList",
"SliverFillViewport"
];
enum SliverType {
SliverGrid,
SliverFixedExtentList,
SliverList,
SliverFillViewport,
}
class SliverSelector extends StatefulWidget {
SliverSelector({Key key, this.clickType, this.mainColor}) : super(key: key);
final ValueChanged<SliverType> clickType;
final Color mainColor;
@override
_SliverState createState() => _SliverState();
}
class _SliverState extends State<SliverSelector> {
void _clickType(pos) {
var type = SliverType.SliverGrid;
switch (pos) {
case 0:
type = SliverType.SliverGrid;
break;
case 1:
type = SliverType.SliverFixedExtentList;
break;
case 2:
type = SliverType.SliverList;
break;
case 3:
type = SliverType.SliverFillViewport;
break;
default:
type = SliverType.SliverGrid;
break;
}
widget.clickType(type);
}
@override
Widget build(BuildContext context) {
return Row(
children: <Widget>[
Expanded(
child: ViewSelector(
title: _SLIVER_TITLE,
values: _SLIVER_VALUES,
mainColor: widget.mainColor,
onClick: _clickType,
),
)
],
);
}
}