-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flutter_web] Form_showDateRangePicker
- Loading branch information
Showing
4 changed files
with
45 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
.../flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Form_showDateRangePicker.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Scaffold(body: Form_showDateRangePicker()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Form_showDateRangePicker extends StatelessWidget { | ||
Form_showDateRangePicker({super.key}); | ||
|
||
final Value<DateTimeRange?> dateRange = (null as DateTimeRange?).signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Watch( | ||
builder: (context) { | ||
return Column( | ||
children: <Widget>[ | ||
Text("date: ${dateRange.value}"), | ||
TextButton.icon( | ||
onPressed: () async { | ||
DateTimeRange? selected = await showDateRangePicker( | ||
context: context, | ||
firstDate: DateTime(DateTime.now().year - 1), | ||
lastDate: DateTime(DateTime.now().year + 1), | ||
); | ||
dateRange.value = selected; | ||
}, | ||
icon: const Icon(Icons.date_range), | ||
label: const Text('showDateRangePicker dialog'), | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters