-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.dart
100 lines (88 loc) · 2.44 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
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:multi_date_range_picker/multi_date_range_picker.dart';
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';
void main() {
Intl.defaultLocale = Intl.verifiedLocale(
Platform.localeName, NumberFormat.localeExists,
onFailure: (_) => 'en_US');
initializeDateFormatting();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyAppPage(),
);
}
}
class MyAppPage extends StatefulWidget {
const MyAppPage({Key key}) : super(key: key);
@override
_MyAppPageState createState() => _MyAppPageState();
}
class _MyAppPageState extends State<MyAppPage> {
List<List<DateTime>> intervals = [
[
DateTime.now().add(Duration(days: -8)),
DateTime.now().add(Duration(days: 1))
]
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Multi Date Range Picker'),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
MultiDateRangePicker(
initialValue: intervals,
onChanged: (List<List<DateTime>> intervals) {
setState(() {
this.intervals = intervals;
});
},
selectionColor: Colors.lightBlueAccent,
buttonColor: Colors.lightBlueAccent,
),
SizedBox(
height: 16,
),
Row(
children: <Widget>[
Expanded(
child: Card(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8.0, vertical: 16.0),
child: Column(
children: buildColumn(),
),
),
),
),
],
)
],
),
),
);
}
List<Widget> buildColumn() {
final List<Widget> list = [];
for (final interval in intervals) {
list.add(Text(interval[0].toString() + " - " + interval[1].toString()));
if (interval != intervals.last)
list.add(SizedBox(
height: 8,
));
}
return list;
}
}