ActionChoiceChip Class

 import "package:flutter/material.dart";


void main()
{
runApp(const MyApp());
}
class MyApp extends StatelessWidget
{
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "ActionChoiceChip Class",
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorSchemeSeed: const Color(0xff6750a4),
),
home: const ActionChipExample(),
);
}
}
class ActionChipExample extends StatefulWidget
{
const ActionChipExample({super.key});
@override
State<ActionChipExample> createState()
{
return ActionChipExampleState();
}
}
class ActionChipExampleState extends State<ActionChipExample>
{
int? _value = 1;

@override
Widget build(BuildContext context) {
final TextTheme textTheme = Theme.of(context).textTheme;

return Scaffold(
appBar: AppBar(
title: const Text("ActionChoiceChip Example"),
centerTitle: true,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text("Choose an item", style: textTheme.labelLarge),
const SizedBox(height: 10.0),
Wrap(
spacing: 5.0,
children: List<Widget>.generate(
11, (int index) {
return ChoiceChip(
label: Text("Item $index"),
selected: _value == index,
onSelected: (bool selected) {
setState(() {
_value = selected ? index : null;
},);
},
);
}).toList(),
),
],
),
),
);
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Pagination with Bloc Pattern in Flutter

If_Else_Example