-
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
72 additions
and
38 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
28 changes: 28 additions & 0 deletions
28
notes/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Form_ActionChip.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_ActionChip()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Form_ActionChip extends StatelessWidget { | ||
Form_ActionChip({super.key}); | ||
|
||
final Value<bool> favorite = false.signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Watch(builder: (context) { | ||
return Column(children: <Widget>[ | ||
Wrap(children: [ | ||
ActionChip( | ||
avatar: Icon(favorite.value ? Icons.favorite : Icons.favorite_border), | ||
label: const Text("favorite"), | ||
onPressed: () => favorite.value = !favorite.value, | ||
), | ||
]), | ||
]); | ||
}); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
notes/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Form_ChoiceChip.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,36 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Scaffold(body: Form_ChoiceChip()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Form_ChoiceChip extends StatelessWidget { | ||
Form_ChoiceChip({super.key}); | ||
|
||
final Value<TargetPlatform?> selected = (null as TargetPlatform?).signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Watch( | ||
builder: (context) { | ||
return Column( | ||
children: <Widget>[ | ||
Wrap( | ||
children: [ | ||
for (var t in TargetPlatform.values) | ||
ChoiceChip( | ||
label: Text(t.name), | ||
selected: selected.value == t, | ||
onSelected: (bool value) { | ||
selected.value = value ? t : null; | ||
}), | ||
], | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
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