Advertisement
fahimkamal63

Carve Navigation Bar

Dec 5th, 2021
1,175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.43 KB | None | 0 0
  1. import 'package:curved_navigation_bar/curved_navigation_bar.dart';
  2. import 'package:flutter/material.dart';
  3.  
  4. class CurveNavigationBarClass extends StatefulWidget {
  5.   const CurveNavigationBarClass({Key? key}) : super(key: key);
  6.  
  7.   @override
  8.   _CurveNavigationBarClassState createState() =>
  9.       _CurveNavigationBarClassState();
  10. }
  11.  
  12. class _CurveNavigationBarClassState extends State<CurveNavigationBarClass> {
  13.   int _curPage = 0;
  14.   List _pages = ['Home', 'Camera', 'Menu'];
  15.  
  16.   GlobalKey<CurvedNavigationBarState> _globalNavKey = GlobalKey();
  17.  
  18.   @override
  19.   Widget build(BuildContext context) {
  20.     return Scaffold(
  21.       appBar: AppBar(
  22.         title: Text("Curve NavBar" + " " + _pages[_curPage]),
  23.         centerTitle: true,
  24.       ),
  25.       bottomNavigationBar: CurvedNavigationBar(
  26.         color: Colors.red,
  27.         backgroundColor: Colors.green,
  28.         buttonBackgroundColor: Colors.yellow,
  29.         animationDuration: Duration(milliseconds: 800),
  30.         animationCurve: Curves.bounceOut,
  31.         key: _globalNavKey,
  32.         index: _curPage,
  33.         onTap: (index) {
  34.           setState(() {
  35.             _curPage = index;
  36.           });
  37.         },
  38.         items: [
  39.           Icon(Icons.home),
  40.           Icon(Icons.camera),
  41.           Icon(Icons.menu),
  42.         ],
  43.       ),
  44.       body: Center(
  45.         child: Text(
  46.           _pages[_curPage],
  47.           style: TextStyle(fontSize: 50),
  48.         ),
  49.       ),
  50.     );
  51.   }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement