Created
May 4, 2021 12:27
-
-
Save rajada1/4b3919c33aa55f12cdf337293eb6cdc9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MaterialApp(home: HomePage())); | |
} | |
class HomePage extends StatefulWidget { | |
@override | |
_HomePageState createState() => _HomePageState(); | |
} | |
class _HomePageState extends State<HomePage> { | |
PageController _pageController = PageController(); | |
List<Widget> _screens = [ | |
Container(), | |
Container(), | |
Container(), | |
Container(), | |
Container(), | |
]; | |
int _selectedIndex = 0; | |
void _onPageChanged(int index) { | |
setState( | |
() { | |
_selectedIndex = index; | |
}, | |
); | |
} | |
void _onItemTapped(int selectedIndex) { | |
_pageController.jumpToPage(selectedIndex); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: PageView( | |
controller: _pageController, | |
children: _screens, | |
onPageChanged: _onPageChanged, | |
physics: NeverScrollableScrollPhysics(), | |
), | |
bottomNavigationBar: BottomNavigationBar( | |
currentIndex: _selectedIndex, | |
// selectedFontSize: 20, | |
type: BottomNavigationBarType | |
.fixed, //das muss dazu, damit mehr als 5 Items möglich. | |
backgroundColor: Color(0xffECECEB), | |
onTap: _onItemTapped, | |
//unselectedFontSize: 12, | |
//selectedFontSize: 12, | |
items: [ | |
BottomNavigationBarItem( | |
icon: Icon(Icons.home, | |
color: _selectedIndex == 0 | |
? Color(0xffF6BE03) | |
: Color(0xffB4B4B3), | |
size: 25), | |
title: Text( | |
'Start', | |
style: TextStyle( | |
color: _selectedIndex == 0 | |
? Color(0xffF6BE03) | |
: Color(0xffB4B4B3), | |
fontSize: 11), | |
), | |
), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.directions_car_rounded, | |
color: | |
_selectedIndex == 1 ? Color(0xffF6BE03) : Color(0xffB4B4B3), | |
size: 25), | |
title: Text( | |
'Portal', | |
style: TextStyle( | |
color: _selectedIndex == 1 | |
? Color(0xffF6BE03) | |
: Color(0xffB4B4B3), | |
fontSize: 11), | |
), | |
), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.euro_rounded, | |
color: | |
_selectedIndex == 2 ? Color(0xffF6BE03) : Color(0xffB4B4B3), | |
size: 25), | |
title: Text( | |
'Förderungen', | |
style: TextStyle( | |
color: _selectedIndex == 2 | |
? Color(0xffF6BE03) | |
: Color(0xffB4B4B3), | |
fontSize: 11), | |
), | |
), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.map, | |
color: | |
_selectedIndex == 3 ? Color(0xffF6BE03) : Color(0xffB4B4B3), | |
size: 25), | |
title: Text( | |
'Karte', | |
style: TextStyle( | |
color: _selectedIndex == 3 | |
? Color(0xffF6BE03) | |
: Color(0xffB4B4B3), | |
fontSize: 11), | |
), | |
), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.timer, | |
color: | |
_selectedIndex == 4 ? Color(0xffF6BE03) : Color(0xffB4B4B3), | |
size: 25), | |
title: Text( | |
'Ladezeit', | |
style: TextStyle( | |
color: _selectedIndex == 4 | |
? Color(0xffF6BE03) | |
: Color(0xffB4B4B3), | |
fontSize: 11), | |
), | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment