Created
September 30, 2020 17:56
-
-
Save rydmike/e97d29789886b9b406618d851d765fff to your computer and use it in GitHub Desktop.
Tooltip always shown with new API on web/desktop even if identical to icon label.
This file contains 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
// Flutter code sample for BottomNavigationBar | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
/// This Widget is the main application widget. | |
class MyApp extends StatelessWidget { | |
static const String _title = 'Flutter Code Sample'; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: _title, | |
home: MyStatefulWidget(), | |
); | |
} | |
} | |
class MyStatefulWidget extends StatefulWidget { | |
MyStatefulWidget({Key key}) : super(key: key); | |
@override | |
_MyStatefulWidgetState createState() => _MyStatefulWidgetState(); | |
} | |
class _MyStatefulWidgetState extends State<MyStatefulWidget> { | |
int _selectedIndex = 0; | |
static const TextStyle optionStyle = | |
TextStyle(fontSize: 30, fontWeight: FontWeight.bold); | |
static const List<Widget> _widgetOptions = <Widget>[ | |
Text( | |
'Index 0: Home', | |
style: optionStyle, | |
), | |
Text( | |
'Index 1: Business', | |
style: optionStyle, | |
), | |
Text( | |
'Index 2: School', | |
style: optionStyle, | |
), | |
]; | |
void _onItemTapped(int index) { | |
setState(() { | |
_selectedIndex = index; | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: const Text('BottomNavigationBar Sample'), | |
), | |
body: Center( | |
child: _widgetOptions.elementAt(_selectedIndex), | |
), | |
bottomNavigationBar: BottomNavigationBar( | |
items: const <BottomNavigationBarItem>[ | |
BottomNavigationBarItem( | |
icon: Icon(Icons.home), | |
label: 'Home', | |
), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.business), | |
label: 'Business', | |
), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.school), | |
label: 'School', | |
), | |
], | |
currentIndex: _selectedIndex, | |
selectedItemColor: Colors.amber[800], | |
onTap: _onItemTapped, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related to Flutter issue report: flutter/flutter#71049