Skip to content

Instantly share code, notes, and snippets.

@gabrielgatu
Last active November 20, 2021 18:11
Show Gist options
  • Select an option

  • Save gabrielgatu/510fc90b9e9b1fd8bddf4dd5c0853eeb to your computer and use it in GitHub Desktop.

Select an option

Save gabrielgatu/510fc90b9e9b1fd8bddf4dd5c0853eeb to your computer and use it in GitHub Desktop.
Flutter2Start - Radio #flutter2start
// ignore_for_file: use_key_in_widget_constructors, prefer_const_constructors, prefer_const_literals_to_create_immutables
import 'package:flutter/material.dart';
void main() {
runApp(App());
}
class App extends StatefulWidget {
@override
_AppState createState() => _AppState();
}
class _AppState extends State<App> {
CardVariant cardVariantChosen = CardVariant.basic;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Futter2Start"),
centerTitle: true,
),
body: Center(
child: body(),
),
),
);
}
Widget body() => Column(
children: [
RadioListTile<CardVariant>(
value: CardVariant.basic,
groupValue: cardVariantChosen,
title: Text("Basic"),
onChanged: (value) => setState(() => cardVariantChosen = value!),
),
RadioListTile<CardVariant>(
value: CardVariant.normal,
groupValue: cardVariantChosen,
title: Text("Normal"),
onChanged: (value) => setState(() => cardVariantChosen = value!),
),
RadioListTile<CardVariant>(
value: CardVariant.pro,
groupValue: cardVariantChosen,
title: Text("Pro"),
onChanged: (value) => setState(() => cardVariantChosen = value!),
),
],
);
}
enum CardVariant {
basic,
normal,
pro,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment