Animated Click Drawer In Flutter

Animated Click Drawer In Flutter:

Screenshot 1 :

Screenshot 2 :

Home.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
  bool isClicked = false;

  AnimationController _controller;
  Animation<double> _open_drawer;
  Animation<double> _open_icon;

  int vab = 0;

  _changeState() {
    if (isClicked) {
      isClicked = false;
      _controller.reverse();
    } else {
      _controller.forward();
      isClicked = true;
    }
  }

  @override
  void initState() {
    super.initState();
    _controller =
        AnimationController(duration: Duration(milliseconds: 500), vsync: this);
    _open_drawer = new Tween<double>(begin: 0.0, end: 100).animate(_controller);
    _open_icon = new Tween<double>(begin: 100, end: 10).animate(_controller);
  }

  @override
  Widget build(BuildContext context) {
    return AnimatedBuilder(
        animation: _controller,
        builder: (BuildContext buildercontext, Widget child) {
          return SafeArea(
              child: Scaffold(
                  backgroundColor: Color(0xFFEFF3F5),
                  body: Stack(children: <Widget>[
                    drawer(),
                    Transform(
                        transform: Matrix4.translationValues(
                            _open_drawer.value, 0.0, 0.0),
                        child: home()),
                  ])));
        });
  }

  Widget drawer() {
    return Padding(
        padding: const EdgeInsets.only(left: 30.0),
        child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              InkWell(
                onTap: () {},
                child: Container(
                  height: 40,
                  width: 40,
                  decoration: BoxDecoration(
                      color: Colors.white,
                      shape: BoxShape.circle,
                      boxShadow: [
                        BoxShadow(
                          color: Colors.grey,
                          blurRadius: 5.0,
                        ),
                      ],
                      border: Border.all(color: Colors.black, width: 1)),
                  child: Icon(
                    Icons.perm_identity,
                    size: 30,
                  ),
                ),
              ),
              SizedBox(
                height: _open_icon.value,
              ),
              InkWell(
                  onTap: () {
                    //favourite
                  },
                  child: Container(
                      height: 40,
                      width: 40,
                      decoration: BoxDecoration(
                          color: Colors.white,
                          shape: BoxShape.circle,
                          boxShadow: [
                            BoxShadow(
                              color: Colors.grey,
                              blurRadius: 5.0,
                            ),
                          ],
                          border: Border.all(color: Colors.black, width: 1)),
                      child: InkWell(
                          onTap: () {
                            /*  Navigator.push(
                                context,
                                MaterialPageRoute(
                                    builder: (context) => Favourite()));*/
                          },
                          child: Icon(
                            Icons.favorite_border,
                            size: 30,
                          )))),
              SizedBox(
                height: _open_icon.value,
              ),
              Container(
                  height: 40,
                  width: 40,
                  decoration: BoxDecoration(
                      color: Colors.white,
                      shape: BoxShape.circle,
                      boxShadow: [
                        BoxShadow(
                          color: Colors.grey,
                          blurRadius: 5.0,
                        )
                      ],
                      border: Border.all(color: Colors.black, width: 1)),
                  child: Icon(Icons.info)),
              SizedBox(
                height: _open_icon.value,
              ),
              Container(
                  height: 40,
                  width: 40,
                  decoration: BoxDecoration(
                      color: Colors.white,
                      shape: BoxShape.circle,
                      boxShadow: [
                        BoxShadow(
                          color: Colors.grey,
                          blurRadius: 5.0,
                        ),
                      ],
                      border: Border.all(color: Colors.black, width: 1)),
                  child: Padding(
                      padding: const EdgeInsets.all(10.0),
                      child: Image(
                          image: AssetImage(
                        'img/logout.png',
                      ))))
            ]));
  }

  Widget home() {
    return Container(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        child: new Scaffold(
            backgroundColor: Color(0xFFEFF3F5),
            appBar: AppBar(
                elevation: 0.0,
                backgroundColor: Colors.transparent,
                leading: InkWell(
                  onTap: () {
                    _changeState();
                  },
                  child: Icon(
                    isClicked ? Icons.close : Icons.menu,
                    color: Colors.black54,
                  ),
                ),
                title: Text(
                  "Flutter",
                  textAlign: TextAlign.center,
                  style: TextStyle(color: Colors.black54, fontSize: 19),
                )),
            body: Container(
                margin: EdgeInsets.all(10),
                child: (Text('Flutter Tutorial')))));
  }
}

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