flutter_platform_dropdown 0.0.4 copy "flutter_platform_dropdown: ^0.0.4" to clipboard
flutter_platform_dropdown: ^0.0.4 copied to clipboard

Flutter platform dropdown package for android and iOS default behaviour

example/lib/main.dart

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.
    );
  }
}
3
likes
90
points
24
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter platform dropdown package for android and iOS default behaviour

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on flutter_platform_dropdown