防采集标记:亢少军老师的课程和资料
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: MyHomePage(),
),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
int _selectedIndex = 1;//当前选中项的索引
final _widgetOptions = [
Text('Index 0: 信息'),
Text('Index 1: 通讯录'),
Text('Index 2: 发现'),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('BottomNavigationBar示例'),
),
body: Center(
child: _widgetOptions.elementAt(_selectedIndex),//居中显示某一个文本
),
//底部导航按钮 包含图标及