-
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
3 changed files
with
69 additions
and
43 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
notes/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Form_CheckboxListTile.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,28 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Scaffold(body: Form_CheckboxListTile()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Form_CheckboxListTile extends StatelessWidget { | ||
Form_CheckboxListTile({super.key}); | ||
|
||
final Value<bool?> checkboxListTile1 = (null as bool?).signal(); | ||
final Value<bool> checkboxListTile2 = false.signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Watch( | ||
builder: (context) { | ||
return Column( | ||
children: <Widget>[ | ||
CheckboxListTile(tristate: true, value: checkboxListTile1.value, title: const Text('tristate: true'), onChanged: (value) => checkboxListTile1.value = value), | ||
CheckboxListTile(tristate: false, value: checkboxListTile2.value, title: const Text('tristate: false'), onChanged: (value) => checkboxListTile2.value = value!), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
notes/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Form_Chip.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,37 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Scaffold(body: Form_Chip()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Form_Chip extends StatelessWidget { | ||
Form_Chip({super.key}); | ||
|
||
final Set<TargetPlatform> targets = Set.of(TargetPlatform.values).signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Watch(builder: (context) { | ||
return Column(children: <Widget>[ | ||
Wrap( | ||
children: [ | ||
for (var target in targets) | ||
Chip( | ||
avatar: CircleAvatar(child: Text(target.name[0])), | ||
label: Text(target.name), | ||
onDeleted: () => targets.remove(target), | ||
) | ||
], | ||
), | ||
FilledButton( | ||
onPressed: () { | ||
targets.clear(); | ||
targets.addAll(TargetPlatform.values); | ||
}, | ||
child: const Text("Reset")), | ||
]); | ||
}); | ||
} | ||
} |
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