Skip to content

Instantly share code, notes, and snippets.

@tianhaoz95
Last active October 10, 2019 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tianhaoz95/6a46f9f4bd287d822d1e7879f97624de to your computer and use it in GitHub Desktop.
Save tianhaoz95/6a46f9f4bd287d822d1e7879f97624de to your computer and use it in GitHub Desktop.
Dumb bottom nav bar with non-trivial tap event listener
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Rock Paper Scissors',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
final List<BottomNavigationBarItem> navItemList = [
BottomNavigationBarItem(
icon: Icon(Icons.casino),
title: Text('Rock!'),
),
BottomNavigationBarItem(
icon: Icon(Icons.casino),
title: Text('Paper!'),
),
BottomNavigationBarItem(
icon: Icon(Icons.casino),
title: Text('Scissor!'),
)
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Rock Paper Scissors')),
body: Center(child: Text('Coming soon ...')),
bottomNavigationBar: BottomNavigationBar(
currentIndex: 0,
/// This is not a non-trivial event listener
/// although it still doesn't do much.
onTap: (int index) {
print('bottom nav bar tapped @ index ' + index.toString());
},
items: navItemList,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment