import 'package:flutter/material.dart';
class buildNavBarItem extends StatefulWidget {
const buildNavBarItem({ Key? key }) : super(key: key);
@override
_buildNavBarItemState createState() => _buildNavBarItemState();
}
class _buildNavBarItemState extends State<buildNavBarItem> {
late int _selectedItemIndex;
@override
Widget build(BuildContext context) {
return
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
NavBarItem(UniconsLine.pen, 0, PravoMainScreen()),
NavBarItem(UniconsLine.home_alt, 1, OrganizationScreen()),
NavBarItem(UniconsLine.setting, 2, JusticeMainScreen()),
],
);
}
Widget NavBarItem(IconData icon, int index, Widget screen) {
return GestureDetector(
onTap: () {
setState(() {
_selectedItemIndex = index;
});
Navigator.push(
context,
MaterialPageRoute(builder: (context) => screen)
);}, // Тут переходит на другой экран, но кнопка возвращается на исходную
child: Container(
height: 50.0,
width: MediaQuery.of(context).size.width / 5.5,
decoration: BoxDecoration(
color: index == _selectedItemIndex ? Colors.white: Color(0xFF007FFF),
borderRadius: BorderRadius.circular(20),
),
child: Icon(icon, size: 44, color: index == _selectedItemIndex ? Color(0xFF007FFF): Colors.white),
),
);
}
}