|
import 'package:flutter/material.dart'; |
|
|
|
void main() => runApp(new MyApp()); |
|
|
|
class MyApp extends StatelessWidget { |
|
// This widget is the root of your application. |
|
@override |
|
Widget build(BuildContext context) { |
|
return new MaterialApp( |
|
title: 'Flutter Floating', |
|
debugShowCheckedModeBanner: false, |
|
theme: new ThemeData( |
|
|
|
primarySwatch: Colors.blue, |
|
), |
|
home: new MyHomePage(title: 'Flutter Float'), |
|
); |
|
} |
|
} |
|
|
|
class MyHomePage extends StatefulWidget { |
|
MyHomePage({Key key, this.title}) : super(key: key); |
|
|
|
final String title; |
|
|
|
@override |
|
_MyHomePageState createState() => new _MyHomePageState(); |
|
} |
|
|
|
class _MyHomePageState extends State<MyHomePage> { |
|
int _cIndex = 0; |
|
|
|
void _incrementTab(index) { |
|
setState(() { |
|
_cIndex = index; |
|
}); |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
|
|
return new Scaffold( |
|
appBar: new AppBar( |
|
title: new Text(widget.title), |
|
), |
|
body: new Center( |
|
child: new Column( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
children: <Widget>[ |
|
|
|
], |
|
), |
|
), |
|
bottomNavigationBar:BottomNavigationBar( |
|
currentIndex: _cIndex, |
|
type: BottomNavigationBarType.fixed , |
|
items: [ |
|
BottomNavigationBarItem( |
|
icon: Icon(Icons.home,color: Color.fromARGB(255, 0, 0, 0)), |
|
title: new Text('Home') |
|
), |
|
BottomNavigationBarItem( |
|
icon: Icon(Icons.power,color: Color.fromARGB(255, 0, 0, 0)), |
|
title: new Text('Power') |
|
) |
|
], |
|
onTap: (index){ |
|
_incrementTab(index); |
|
}, |
|
), |
|
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, |
|
floatingActionButton: new FloatingActionButton( |
|
|
|
onPressed:(){ _incrementTab(1); }, |
|
tooltip: 'Increment', |
|
child: new Icon(Icons.add), |
|
), |
|
); |
|
} |
|
} |
How do i man the selected index to navigate to a new screen