Skip to content

Commit

Permalink
Added DateRange picker demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Alabhya268 committed Nov 28, 2020
1 parent 4374701 commit 5db4847
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/routes/nav_dialogs_ex.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

// Adapted from Eajy's flutter demo app:
// https://github.com/Eajy/flutter_demo/blob/master/lib/route/homeDialogs.dart.
Expand Down Expand Up @@ -126,6 +127,28 @@ class DialogsExample extends StatelessWidget {
},
child: const Text('Date Picker Dialog'),
),
////// DateRange Picker Dialog.
RaisedButton(
color: Colors.purple,
onPressed: () {
showDateRangePicker(
context: context,
firstDate: DateTime(2018),
lastDate: DateTime(2025),
).then((DateTimeRange value) {
if (value != null) {
DateTimeRange _fromRange =
DateTimeRange(start: DateTime.now(), end: DateTime.now());
_fromRange = value;
final String range = '${DateFormat.yMMMd().format(_fromRange.start)} - ${DateFormat.yMMMd().format(_fromRange.end)}';
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(range)),
);
}
});
},
child: const Text('Date Picker Dialog'),
),
////// Bottom Sheet Dialog.
RaisedButton(
color: Colors.orange,
Expand Down

0 comments on commit 5db4847

Please sign in to comment.