blob: 520b6aeb22899dcfa6e071fb32fc3e139edac419 [file] [log] [blame] [edit]
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
/// Flutter code sample for [RadioListTile].
void main() => runApp(const RadioListTileApp());
class RadioListTileApp extends StatelessWidget {
const RadioListTileApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('RadioListTile Sample')),
body: const RadioListTileExample(),
),
);
}
}
enum SingingCharacter { lafayette, jefferson }
class RadioListTileExample extends StatefulWidget {
const RadioListTileExample({super.key});
@override
State<RadioListTileExample> createState() => _RadioListTileExampleState();
}
class _RadioListTileExampleState extends State<RadioListTileExample> {
SingingCharacter? _character = SingingCharacter.lafayette;
@override
Widget build(BuildContext context) {
return RadioGroup<SingingCharacter>(
groupValue: _character,
onChanged: (SingingCharacter? value) {
setState(() {
_character = value;
});
},
child: const Column(
children: <Widget>[
RadioListTile<SingingCharacter>(
title: Text('Lafayette'),
value: SingingCharacter.lafayette,
),
RadioListTile<SingingCharacter>(
title: Text('Thomas Jefferson'),
value: SingingCharacter.jefferson,
),
],
),
);
}
}