1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-12 15:58:32 +00:00

Add Radios, CircularProgressIndicator and LinearProgressIndicator to the demo app (#1442)

* Added Radios, CircularProgressIndicator and LinearProgressIndicator

* Modified README

* Fixed readme comment

* Changed layout of indicators

* Ran Flutter format command

* Put two indicators to one row

* Fixed comment

* Ran flutter format

Co-authored-by: Qun Cheng <quncheng@google.com>
This commit is contained in:
Qun Cheng
2022-09-27 15:13:36 -07:00
committed by GitHub
parent 07a613266c
commit 0e46ac55a6
3 changed files with 108 additions and 2 deletions

View File

@@ -42,6 +42,10 @@ class ComponentScreen extends StatelessWidget {
colDivider,
const Checkboxes(),
colDivider,
const Radios(),
colDivider,
const ProgressIndicators(),
colDivider,
showNavBottomBar
? const NavigationBars(
selectedIndex: 0,
@@ -629,6 +633,98 @@ class _CheckboxRowState extends State<CheckboxRow> {
}
}
enum Value { first, second }
class Radios extends StatefulWidget {
const Radios({super.key});
@override
State<Radios> createState() => _RadiosState();
}
class _RadiosState extends State<Radios> {
Value? _value = Value.first;
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Radio<Value>(
value: Value.first,
groupValue: _value,
onChanged: (value) {
setState(() {
_value = value;
});
},
),
Radio<Value>(
value: Value.second,
groupValue: _value,
onChanged: (value) {
setState(() {
_value = value;
});
},
),
],
);
}
}
class ProgressIndicators extends StatefulWidget {
const ProgressIndicators({super.key});
@override
State<ProgressIndicators> createState() => _ProgressIndicatorsState();
}
class _ProgressIndicatorsState extends State<ProgressIndicators> {
bool playProgressIndicator = false;
@override
Widget build(BuildContext context) {
final double? progressValue = playProgressIndicator ? null : 0.7;
return Column(
children: <Widget>[
Row(
children: [
IconButton(
isSelected: playProgressIndicator,
selectedIcon: const Icon(Icons.pause),
icon: const Icon(Icons.play_arrow),
onPressed: () {
setState(() {
playProgressIndicator = !playProgressIndicator;
});
},
),
Expanded(
child: Row(
children: <Widget>[
CircularProgressIndicator(
value: progressValue,
),
const SizedBox(
width: 10,
),
Expanded(
child: LinearProgressIndicator(
value: progressValue,
),
)
],
),
),
],
),
],
);
}
}
const List<NavigationDestination> appBarDestinations = [
NavigationDestination(
tooltip: 'Updated component list',