GetX DropdownMenu

 import "package:flutter/material.dart";

import "package:get/get.dart";

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

@override
Widget build(BuildContext context) {
return GetMaterialApp(
debugShowCheckedModeBanner: false,
title: "Drop Down Menu",
theme: ThemeData(
primarySwatch: Colors.grey,
),
home: DropDownDemo(),
);
}
}
class DropDownDemo extends StatefulWidget {
DropDownDemo({super.key});

@override
State<DropDownDemo> createState() => _DropDownDemoState();
}

class _DropDownDemoState extends State<DropDownDemo> {

String dropdownValue = "Red";

List<String> listItem = <String>[
"Red", "Green", "Orange", "Blue", "Black", "Brown", "White", "Silver"
];

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Drop Down Demo"),
centerTitle: true,
),
body: Center(
child: DropdownButton(
dropdownColor: Colors.grey.shade400,
value: dropdownValue,
items: listItem.map<DropdownMenuItem<String>>(
(String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
},
).toList(),
onChanged: (String? newValue) {
setState(() {
dropdownValue = newValue!;
},);
},
),
),
);
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter