Saturday, August 15, 2020

DropDown | Multiple DropDown | BottomSheet

 DropDown And Multiple DropDown In Flutter

.............................................................................................................................................................................................................................................
Example: #1

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: MyApp()));

class MyApp extends StatefulWidget {
@override
MyAppState createState() => MyAppState();
}

class MyAppState extends State<MyApp> {
String valu="";
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Hello World"),
),
body: Center(
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.all(15.0),
child: DropdownButton<String>(
hint: Text('Select any numbers'),
items: [
DropdownMenuItem<String>(
value: '1',
child: Center(
child: Text('One'),
),
),
DropdownMenuItem<String>(
value: '2',
child: Center(
child: Text('Two'),
),
) ,
DropdownMenuItem<String>(
value: '3',
child: Center(
child: Text('Three'),
),
)

],
onChanged: (_value) => {

print(_value.toString()),
setState((){
valu=_value ;
})
},

),

),
Text('${valu}')
],

),
));
}
}

.............................................................................................................................................................................................................................................
Example: #2

import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
        home: MyApp(
      title: 'Bottom Sheet',
    )));

class MyApp extends StatefulWidget {
  MyApp({Key key, this.title}) : super(key: key);
  final String title;
  @override
  MyAppState createState() => MyAppState();
}

class MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: RaisedButton(
          onPressed: () {
            _bottomSheet(context);
          },
          color: Colors.blue,
          child: Text('Press Me', style: TextStyle(color: Colors.white)),
        ),
      ),
    );
  }
  _bottomSheet(context) {
    showModalBottomSheet(
      context: context,
      builder: (BuildContext context) {
        return Wrap(
          children: [
            Container(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Padding(
                    padding: EdgeInsets.all(20.0),
                    child: Text('Login', style: TextStyle(fontSize: 18.0, color: Colors.red)),
                  ),
                  Divider(height: 50.0),
                  ListTile(
                    leading: Image.asset('assets/images/download.png', height: 30.0,),
                    title: Text('Login with Google'),
                  ),
                  ListTile(
                    leading: Image.asset('assets/images/facebook.png', height: 30.0,),
                    title: Text('Login with Facebook'),
                  ),
                ],
              ),
            ),
          ],
        );
      },
    );
  }
}

...........................................................................................................................................................................................................................................
Example: #3

.............................................................................................................................................................................................................................................
Example: #4


No comments:

Post a Comment