Bottom Sheet In Flutter

Bottom Sheet In Flutter :

This flutter tutorial post Bottom Sheet in flutter.

add dependencies
share:

Provide functionality
1) Bottom sheet
2) Share
3) Dialog

Screenshot 1 :

Bottom Sheet In Flutter

Screenshot 2 :

Bottom Sheet In Flutter

Screenshot 3 :

Bottom Sheet In Flutter

main.dart

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:share/share.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  showPopup() {
    showDialog(
      context: context,
      builder: (BuildContext context) {
        // return object of type Dialog
        return AlertDialog(
          title: new Text("Flutter start"),
          content: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Container(
                child: new Text(
                  "- Flutter Basic \n- Widgets \n- Method channel \n- Pattern \n- Database \n- Api call \n- Social Login \n- Map \n- Firebase \n- Live chatting \n- Read and Write File",
                  style: TextStyle(
                    color: Colors.black,
                    fontSize: 14.0,
                  ),
                ),
              ),
              SizedBox(
                height: 20,
              ),

              RichText(
                text: TextSpan(
                  children: [
                    TextSpan(
                      text: 'Visit the flutter website ',
                      style: TextStyle(
                        color: Colors.black,
                        fontSize: 14.0,
                      ),
                    ),
                    TextSpan(
                      text: 'www.fluttertutorial.in',
                      style: TextStyle(
                        decoration: TextDecoration.underline,
                        color: Colors.blue,
                        fontSize: 14.0,
                      ),
                      recognizer: new TapGestureRecognizer()
                        ..onTap = () {
                          Navigator.of(context).pop();
                        },
                    ),
                  ],
                ),
              ),
            ],
          ),
          actions: <Widget>[
            // usually buttons at the bottom of the dialog
            new FlatButton(
              child: new Text("Close"),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );
  }

  Widget bottomBar(String referral) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisSize: MainAxisSize.min,
      children: <Widget>[
        SizedBox(
          height: 16,
        ),
        Container(
            height: 40,
            padding: EdgeInsets.only(top: 4),
            color: Colors.white,
            child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Text("Lean Flutter",
                      style: TextStyle(
                        color: Colors.black,
                        fontWeight: FontWeight.bold,
                        fontSize: 16.0,
                      ))
                ])),
        Container(
            padding: EdgeInsets.only(right: 16, left: 16, bottom: 16),
            child:
                Text("Next generation language.",
                    textAlign: TextAlign.justify,
                    style: TextStyle(
                      color: Color(0xFF636466),
                      fontSize: 14.0,
                    ))),
        Divider(
          height: 1,
        ),
        Container(
            padding: EdgeInsets.all(8),
            child: Text('SHARE YOUR INVITE CODE',
                style: TextStyle(
                  color: Colors.black.withOpacity(0.6),
                  fontSize: 12.0,
                ))),
        Container(
            height: 40,
            padding: EdgeInsets.only(top: 4),
            color: Colors.white,
            child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  InkWell(
                      onTap: () {
                        Navigator.pop(context);
                      },
                      child: Container(
                          padding: EdgeInsets.all(8),
                          child: Text("How it works",
                              style: TextStyle(
                                color: Colors.blue,
                                fontWeight: FontWeight.bold,
                                fontSize: 14.0,
                              )))),
                  Padding(
                      padding: const EdgeInsets.only(left: 8, right: 8),
                      child: Container(
                        height: 24,
                        width: 1,
                        color: Colors.grey.withOpacity(0.5),
                      )),
                  InkWell(
                      onTap: () {
                        Navigator.pop(context);
                        showPopup();
                      },
                      child: Container(
                          padding: EdgeInsets.all(8),
                          child: Text("Start Flutter",
                              style: TextStyle(
                                color: Colors.blue,
                                fontWeight: FontWeight.bold,
                                fontSize: 14.0,
                              ))))
                ])),
        Container(
            padding: EdgeInsets.all(16),
            child: Text(referral,
                style: TextStyle(
                  color: Colors.black,
                  fontWeight: FontWeight.bold,
                  fontSize: 20.0,
                ))),
        InkWell(
            onTap: () {
              Navigator.pop(context);
              Share.share(
                  "Flutter world best website www.fluttertutorial.in");
            },
            child: Container(
                padding:
                    EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4),
                decoration: new BoxDecoration(
                    color: Colors.white,
                    borderRadius: new BorderRadius.circular(4.0),
                    border: Border.all(
                      color: Colors.green,
                      width: 1,
                    ),
                    boxShadow: <BoxShadow>[
                      BoxShadow(
                          color: Colors.black.withOpacity(0.2),
                          offset: Offset(0, 1),
                          blurRadius: 5.0),
                    ]),
                child: Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Text('Share'.toUpperCase(),
                        style: TextStyle(
                          color: Colors.green,
                          fontSize: 12.0,
                        ))))),
        Container(
          height: 16,
        )
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          // Here we take the value from the MyHomePage object that was created by
          // the App.build method, and use it to set our appbar title.
          title: Text("Bottom Sheet Flutter"),
        ),
        body: Center(
            child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
              Text(
                'You have pushed the button open the bottom sheet.',
              )
            ])),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            showModalBottomSheet<void>(
              context: context,
              builder: (BuildContext context) => bottomBar('Please share website'),
            );
          },
          tooltip: 'Increment',
          child: Icon(Icons.add),
        ) // This trailing comma makes auto-formatting nicer for build methods.
        );
  }
}

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in