import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatefulWidget {
@override
_MyWidgetState createState() => _MyWidgetState();
}
List<String> etiketler = ["bu", "bir", "etiket", "droidim", "com"];
List<int> seciliListe = List.generate(5, (index) => index);
class _MyWidgetState extends State<MyWidget> {
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Lütfen etiketlerinizi seçin"),
for (String etiket in etiketler)
FilterChip(
label: Text(etiket),
selected: seciliListe.contains(etiketler.indexOf(etiket)),
onSelected: (value) {
int etiketIndex = etiketler.indexOf(etiket);
setState(() {
if (value) {
seciliListe.add(etiketIndex);
} else {
seciliListe.remove(etiketIndex);
}
});
},
)
],
);
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.