-
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.
- Loading branch information
Showing
4 changed files
with
77 additions
and
33 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
32 changes: 32 additions & 0 deletions
32
...s/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Form_CalendarDatePicker.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,32 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Scaffold(body: Form_CalendarDatePicker()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Form_CalendarDatePicker extends StatelessWidget { | ||
Form_CalendarDatePicker({super.key}); | ||
|
||
final Value<DateTime?> date = (null as DateTime?).signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Watch( | ||
builder: (context) { | ||
return Column( | ||
children: <Widget>[ | ||
Text("date: ${date.value}"), | ||
CalendarDatePicker( | ||
initialDate: DateTime.now(), | ||
firstDate: DateTime(DateTime.now().year - 1), | ||
lastDate: DateTime(DateTime.now().year + 1), | ||
onDateChanged: (value) => date.value = value, | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
notes/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Form_showDatePicker.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,39 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Scaffold(body: Form_showDatePicker()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Form_showDatePicker extends StatelessWidget { | ||
Form_showDatePicker({super.key}); | ||
|
||
final Value<DateTime?> date = (null as DateTime?).signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Watch( | ||
builder: (context) { | ||
return Column( | ||
children: <Widget>[ | ||
Text("date: ${date.value}"), | ||
TextButton.icon( | ||
onPressed: () async { | ||
DateTime? selected = await showDatePicker( | ||
context: context, | ||
initialDate: DateTime.now(), | ||
firstDate: DateTime(DateTime.now().year - 1), | ||
lastDate: DateTime(DateTime.now().year + 1), | ||
); | ||
date.value = selected; | ||
}, | ||
icon: const Icon(Icons.calendar_month), | ||
label: const Text('showDatePicker 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