Skip to content

Instantly share code, notes, and snippets.

@HudsonAfonso
Created July 1, 2019 19:54
Show Gist options
  • Save HudsonAfonso/4acbeba9ad9be960ab75bd9f8253343f to your computer and use it in GitHub Desktop.
Save HudsonAfonso/4acbeba9ad9be960ab75bd9f8253343f to your computer and use it in GitHub Desktop.
Radio
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
int _radioValue1 = -1;
void _handleRadioValueChange1(int value) {
setState(() {
_radioValue1 = value;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text('Radio'),
),
body: Container(
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Radio(
value: 0,
groupValue: _radioValue1,
onChanged: _handleRadioValueChange1,
),
new Text(
'Valor 1',
style: new TextStyle(fontSize: 16.0),
),
new Radio(
value: 1,
groupValue: _radioValue1,
onChanged: _handleRadioValueChange1,
),
new Text(
'Valor 2',
style: new TextStyle(
fontSize: 16.0,
),
),
new Radio(
value: 2,
groupValue: _radioValue1,
onChanged: _handleRadioValueChange1,
),
new Text(
'Valor 3',
style: new TextStyle(fontSize: 16.0),
),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment