Home > other >  How to design this bottom navigation bar in flutter
How to design this bottom navigation bar in flutter

Time:08-28

Screenshot

Is there any dependency available that can easily design this bottom navigation bar?

CodePudding user response:

check packages animated_bottom_navigation_bar and curved_navigation_bar

CodePudding user response:

you can achieve this without any external package of course by using a stack and a couple of containers have a look at the following code:

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

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

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> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Stack(
        children: [
          Column(
            mainAxisAlignment: MainAxisAlignment.end,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              Row(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  Expanded(
                    flex: 3,
                    child: Container(
                      height: 80.0,
                      decoration: BoxDecoration(
                        color: Colors.pink,
                        borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(
                            30.0,
                          ),
                          topRight: Radius.circular(
                            15.0,
                          ),
                        ),
                      ),
                    ),
                  ),
                  Expanded(
                    flex: 2,
                    child: Container(
                      height: 60.0,
                      decoration: BoxDecoration(
                        color: Colors.pink,
                      ),
                    ),
                  ),
                  Expanded(
                    flex: 3,
                    child: Container(
                      height: 80.0,
                      decoration: BoxDecoration(
                        color: Colors.pink,
                        borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(
                            15.0,
                          ),
                          topRight: Radius.circular(
                            30.0,
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ],
          ),
          Padding(
            padding: EdgeInsets.only(
              bottom: 15.0,
            ),
            child: Align(
              alignment: Alignment.bottomCenter,
              child: Container(
                height: 90.0,
                width: 90.0,
                decoration: BoxDecoration(
                  color: Colors.black,
                  borderRadius: BorderRadius.circular(
                    45.0,
                  ),
                ),
              ),
            ),
          ),
          Padding(
            padding: EdgeInsets.only(
              bottom: 25.0,
            ),
            child: Align(
              alignment: Alignment.bottomCenter,
              child: Container(
                height: 70.0,
                width: 70.0,
                decoration: BoxDecoration(
                  color: Colors.pink,
                  borderRadius: BorderRadius.circular(
                    35.0,
                  ),
                ),
              ),
            ),
          ),
          Padding(
            padding: EdgeInsets.only(
              bottom: 30.0,
            ),
            child: Align(
              alignment: Alignment.bottomCenter,
              child: Container(
                height: 60.0,
                width: 60.0,
                decoration: BoxDecoration(
                  color: Colors.black,
                  borderRadius: BorderRadius.circular(
                    30.0,
                  ),
                ),
                child: Icon(
                  CupertinoIcons.home,
                  color: Colors.pink,
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

code output

this is an example of how to do it. If you want to implement the order and notifications buttons and the others, you can split the first container in the Row() into two containers, and by playing a little bit with margins, you can achieve this design very quickly.

remember that there are other thousands of ways to do it, it just depends on how much you know about flutter widgets.

hope this help

  • Related