import 'package:flutter/material.dart';
import 'each_view.dart';
class BottomAppBarDemo extends StatefulWidget {
//const BottomAppBarDemo({super.key});
@override
State<BottomAppBarDemo> createState() => _BottomAppBarDemoState();
}
class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
late List<Widget> _eachView;
int _index = 0;
@override
void initState() {
super.initState();
_eachView = [];
_eachView
..add(EachView("Home"))
..add(EachView("Jspany"));
// TODO: implement setState
//super.setState(fn);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: _eachView[_index],
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (ctx) {
return EachView("new page");
}));
},
tooltip: "JSPang",
child: Icon(
Icons.add,
color: Colors.white,
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: BottomAppBar(
color: Colors.lightBlue,
shape: CircularNotchedRectangle(),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
IconButton(
icon: Icon(Icons.home),
color: Colors.white,
onPressed: () {
setState(() {
_index = 0;
});
},
),
IconButton(
icon: Icon(Icons.air_rounded),
color: Colors.white,
onPressed: () {
setState(() {
_index = 1;
});
},
)
],
),
),
);
}
}