mukki_bassist

Test DropDown Search

Dec 6th, 2021
716
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'package:flutter/material.dart';
  2. import 'package:dropdown_search/dropdown_search.dart';
  3.  
  4. void main() {
  5.   runApp(MyApp());
  6. }
  7.  
  8. class MyApp extends StatefulWidget {
  9.   @override
  10.   Widget build(BuildContext context) {
  11.     return MaterialApp(
  12.       home: HomePage(),
  13.     );
  14.   }
  15. }
  16. class HomePage extends StatefulWidget{
  17.   @override
  18.   _HomePageState createState()==> _HomePageState();
  19. }
  20.  
  21. class _HomePageState extends State<HomePage> {
  22.   @override
  23.   Widget build(BuildContext context) {
  24.     return Scaffold(
  25.       appBar: AppBar(
  26.         title: const Text("Dropdown"),
  27.       ),
  28.       body: Center(
  29.         child: DropdownSearch<String>(
  30.     mode: Mode.MENU,
  31.     showSelectedItem: true,
  32.     items: ["Brazil", "Italia (Disabled)", "Tunisia", 'Canada'],
  33.     label: "Menu mode",
  34.     hint: "country in menu mode",
  35.     popupItemDisabled: (String s) => s.startsWith('I'),
  36.     onChanged: print,
  37.     selectedItem: "Brazil"),
  38.            
  39.       ),
  40.     );
  41.   }
  42. }
  43.  
RAW Paste Data