Skip to content

Commit

Permalink
[flutter_web] Form_radio
Browse files Browse the repository at this point in the history
  • Loading branch information
chen56 committed Jun 14, 2024
1 parent 439ae5b commit 0f13e03
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 92 deletions.
3 changes: 3 additions & 0 deletions notes/flutter_web/lib/assets.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ mixin AssetsMixin {
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_ButtonStyleButton_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_ButtonStyleButton.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Navigation_BottomAppBar_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Navigation_BottomAppBar.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Navigation_Menu_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Navigation_Menu.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_DropdownMenu_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_DropdownMenu.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Navigation_TabBar_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Navigation_TabBar.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Navigation_NavigationDrawer_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Navigation_NavigationDrawer.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Spacer_Placeholder_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Spacer_Placeholder.dart');
Expand All @@ -114,12 +115,14 @@ mixin AssetsMixin {
final Asset lib_routes_notes_cheatsheets_widgets__examples_Navigation_SliverAppBar_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Navigation_SliverAppBar.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_LayoutCore_ContainerCell_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/LayoutCore_ContainerCell.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Navigation_AppBar_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Navigation_AppBar.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_showTimePicker_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_showTimePicker.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_SearchAnchor_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_SearchAnchor.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_FilterChip_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_FilterChip.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_FloatingActionButton_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_FloatingActionButton.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_CheckboxListTile_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_CheckboxListTile.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Navigation_NavigationBar_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Navigation_NavigationBar.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Spacer_Spacer_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Spacer_Spacer.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_Radio_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_Radio.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_InputChip_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_InputChip.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Navigation_NavigationRail_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Navigation_NavigationRail.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_SegmentButton_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_SegmentButton.dart');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';

main() {
runApp(const MaterialApp(home: Scaffold(body: Form_DropdownMenu())));
}

// ignore: camel_case_types
class Form_DropdownMenu extends StatelessWidget {
const Form_DropdownMenu({super.key});

@override
Widget build(BuildContext context) {
return Column(
children: [
Wrap(crossAxisAlignment: WrapCrossAlignment.center, children: [
const Text("enableFilter: true "),
DropdownMenu<TargetPlatform>(
label: const Text('platform'),
enableFilter: true,
onSelected: (value) {},
dropdownMenuEntries: TargetPlatform.values.map((e) {
return DropdownMenuEntry<TargetPlatform>(value: e, label: e.name);
}).toList(),
)
]),
Wrap(crossAxisAlignment: WrapCrossAlignment.center, children: [
const Text("enableFilter: false"),
DropdownMenu<TargetPlatform>(
label: const Text('platform'),
enableFilter: false,
onSelected: (value) {},
dropdownMenuEntries: TargetPlatform.values.map((e) {
return DropdownMenuEntry<TargetPlatform>(value: e, label: e.name);
}).toList(),
),
]),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'package:you_flutter/state.dart';

main() {
runApp(MaterialApp(home: Scaffold(body: Form_Radio())));
}

// ignore: camel_case_types
class Form_Radio extends StatelessWidget {
Form_Radio({super.key});

final List<TargetPlatform> targets = List.of([TargetPlatform.linux, TargetPlatform.windows, TargetPlatform.macOS]);
final Value<TargetPlatform?> radioListTile = (null as TargetPlatform?).signal();
final Value<TargetPlatform?> radio = (null as TargetPlatform?).signal();

@override
Widget build(BuildContext context) {
return Watch(
builder: (context) {
return Column(
children: <Widget>[
Wrap(
children: [
const Text("RadioListTile:"),
for (var t in targets)
RadioListTile<TargetPlatform>(
title: Text(t.name),
value: t,
groupValue: radioListTile.value,
toggleable: true,
onChanged: (value) => radioListTile.value = value,
),
const Text("Radio:"),
for (var t in targets)
ListTile(
title: Text(t.name),
leading: Radio<TargetPlatform>(
value: t,
groupValue: radio.value,
onChanged: (value) => radio.value = value,
),
),
],
),
],
);
},
);
}
}
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_showTimePicker())));
}

// ignore: camel_case_types
class Form_showTimePicker extends StatelessWidget {
Form_showTimePicker({super.key});

final Value<TimeOfDay?> time = (null as TimeOfDay?).signal();

@override
Widget build(BuildContext context) {
return Watch(
builder: (context) {
return Column(
children: <Widget>[
Text("date: ${time.value}"),
TextButton.icon(
onPressed: () async {
TimeOfDay? selected = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
time.value = selected;
},
icon: const Icon(Icons.timer_outlined),
label: const Text('showTimePicker dialog'),
),
],
);
},
);
}
}
98 changes: 6 additions & 92 deletions notes/flutter_web/lib/routes/notes/cheatsheets/widgets/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_Chec
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_CheckboxListTile.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_Chip.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_ChoiceChip.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_DropdownMenu.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_FilterChip.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_FloatingActionButton.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_IconButton.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_InputChip.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_SearchAnchor.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_SegmentButton.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_Radio.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_showDatePicker.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_showDateRangePicker.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_showTimePicker.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/LayoutCore_ContainerCell.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Navigation_AppBar.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Navigation_BottomAppBar.dart';
Expand Down Expand Up @@ -75,9 +78,9 @@ void build(BuildContext context, Cell print) {
FlutterExample(title: "showDateRangePicker", source: assets.lib_routes_notes_cheatsheets_widgets__examples_Form_showDateRangePicker_dart, child: Form_showDateRangePicker()),
FlutterExample(title: "showDatePicker", source: assets.lib_routes_notes_cheatsheets_widgets__examples_Form_showDatePicker_dart, child: Form_showDatePicker()),
FlutterExample(title: "CalendarDatePicker", source: assets.lib_routes_notes_cheatsheets_widgets__examples_Form_CalendarDatePicker_dart, child: Form_CalendarDatePicker()),
FlutterExample(title: "timePicker", child: buttonAndInput.timePicker()),
FlutterExample(title: "DropdownMenu", child: buttonAndInput.dropdownMenu()),
FlutterExample(title: "Radio", child: buttonAndInput.radio()),
FlutterExample(title: "showTimePicker", source: assets.lib_routes_notes_cheatsheets_widgets__examples_Form_showTimePicker_dart, child: Form_showTimePicker()),
FlutterExample(title: "Radio", source: assets.lib_routes_notes_cheatsheets_widgets__examples_Form_Radio_dart, child: Form_Radio()),
FlutterExample(title: "DropdownMenu", source: assets.lib_routes_notes_cheatsheets_widgets__examples_Form_DropdownMenu_dart, child: Form_DropdownMenu()),
FlutterExample(title: "Slider", child: buttonAndInput.slider()),
FlutterExample(title: "Switch", child: buttonAndInput.switchs()),
FlutterExample(title: "TextField", child: buttonAndInput.textField()),
Expand All @@ -103,95 +106,6 @@ void build(BuildContext context, Cell print) {
}

class ButtonAndInput {
Widget timePicker() {
final Value<TimeOfDay?> time = (null as TimeOfDay?).signal();
return Watch(
builder: (context) {
return Column(
children: <Widget>[
Text("date: ${time.value}"),
TextButton.icon(
onPressed: () async {
TimeOfDay? selected = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
time.value = selected;
},
icon: const Icon(Icons.timer_outlined),
label: const Text('showTimePicker dialog'),
),
],
);
},
);
}

Widget dropdownMenu() {
return Column(
children: [
Wrap(crossAxisAlignment: WrapCrossAlignment.center, children: [
const Text("enableFilter: true "),
DropdownMenu<TargetPlatform>(
label: const Text('platform'),
enableFilter: true,
onSelected: (value) {},
dropdownMenuEntries: TargetPlatform.values.map((e) {
return DropdownMenuEntry<TargetPlatform>(value: e, label: e.name);
}).toList(),
)
]),
Wrap(crossAxisAlignment: WrapCrossAlignment.center, children: [
const Text("enableFilter: false"),
DropdownMenu<TargetPlatform>(
label: const Text('platform'),
enableFilter: false,
onSelected: (value) {},
dropdownMenuEntries: TargetPlatform.values.map((e) {
return DropdownMenuEntry<TargetPlatform>(value: e, label: e.name);
}).toList(),
),
]),
],
);
}

Widget radio() {
List<TargetPlatform> targets = List.of([TargetPlatform.linux, TargetPlatform.windows, TargetPlatform.macOS]);
final Value<TargetPlatform?> radioListTile = (null as TargetPlatform?).signal();
final Value<TargetPlatform?> radio = (null as TargetPlatform?).signal();
return Watch(
builder: (context) {
return Column(
children: <Widget>[
Wrap(
children: [
const Text("RadioListTile:"),
for (var t in targets)
RadioListTile<TargetPlatform>(
title: Text(t.name),
value: t,
groupValue: radioListTile.value,
toggleable: true,
onChanged: (value) => radioListTile.value = value,
),
const Text("Radio:"),
for (var t in targets)
ListTile(
title: Text(t.name),
leading: Radio<TargetPlatform>(
value: t,
groupValue: radio.value,
onChanged: (value) => radio.value = value,
),
),
],
),
],
);
},
);
}

Widget slider() {
final Value<double> slider1 = 0.0.signal();
Expand Down

0 comments on commit 0f13e03

Please sign in to comment.