App Bar - ConvexApp

 ConvexApp 





Add  Dependencies in Pubspec.yaml:
Open [ pubspec.yaml ]

Copy and Paste in pubspec.yaml 
convex_bottom_bar: ^3.0.0



Click  [ Pub upgrade ]  :- Note ; Internet Connection Required




Source Code


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

void main() {
runApp( MaterialApp(
title:" ConvexApp ",
home:Scaffold(appBar: AppBar(title: Text(' ConvexApp ',),),
body: Material(
child: Center(
child:
ConvexAppExample()
,
),
) ,
),
));
}




const _kPages = <String, IconData>{
'home': Icons.home,
'map': Icons.map,
'add': Icons.add,
'message': Icons.message,
'people': Icons.people,
};

class ConvexAppExample extends StatefulWidget {
const ConvexAppExample({Key? key}) : super(key: key);

@override
_ConvexAppExampleState createState() => _ConvexAppExampleState();
}

class _ConvexAppExampleState extends State<ConvexAppExample> {
TabStyle _tabStyle = TabStyle.reactCircle;

@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 5,
initialIndex: 2,
child: Scaffold(
body: Column(
children: [
_buildStyleSelector(),
const Divider(),
Expanded(
child: TabBarView(
children: [
for (final icon in _kPages.values) Icon(icon, size: 64),
],
),
),
],
),
bottomNavigationBar: ConvexAppBar.badge(
// Optional badge argument: keys are tab indices, values can be
// String, IconData, Color or Widget.
/*badge=*/ const <int, dynamic>{3: '99+'},
style: _tabStyle,
items: <TabItem>[
for (final entry in _kPages.entries)
TabItem(icon: entry.value, title: entry.key),
],
onTap: (int i) => print('click index=$i'),
),
),
);
}

// Select style enum from dropdown menu:
Widget _buildStyleSelector() {
final dropdown = DropdownButton<TabStyle>(
value: _tabStyle,
onChanged: (newStyle) {
if (newStyle != null) setState(() => _tabStyle = newStyle);
},
items: [
for (final style in TabStyle.values)
DropdownMenuItem(
value: style,
child: Text(style.toString()),
)
],
);
return ListTile(
contentPadding: const EdgeInsets.all(8),
title: const Text('appbar style:'),
trailing: dropdown,
);
}
}


Comments