flutter_platform_dropdown 0.0.4 flutter_platform_dropdown: ^0.0.4 copied to clipboard
Flutter platform dropdown package for android and iOS default behaviour
import 'package:flutter/material.dart';
import 'package:flutter_platform_dropdown/flutter_platform_dropdown.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Platform Dropdown',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Platform Dropdown example'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
List<DropDownModel> list = [];
String selectedItem="";
@override
void initState() {
// TODO: implement initState
super.initState();
list.add(DropDownModel(text: "Item 1", value: "1"));
list.add(DropDownModel(text: "Item 2", value: "2"));
list.add(DropDownModel(text: "Item 3", value: "3"));
list.add(DropDownModel(text: "Item 4", value: "4"));
list.add(DropDownModel(text: "Item 5", value: "5"));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
PlatformDropdown(
width: 200,
selectedValue: selectedItem,
items: list,
onChange: (val)
{
setState(() {
selectedItem = val;
});
}
)
],
),
),// This trailing comma makes auto-formatting nicer for build methods.
);
}
}