@override
Widget build(BuildContext context) {
//SafeArea 适配刘海屏等
return Scaffold(
/**
- appBar
*/
appBar: AppBar(
title: Text(
_appBarTitle[_currentIndex],
style: TextStyle(color: Color(AppColors.APPBAR)),),
),
/**
*body
*/
//body的pager的滑动PageView来协助实现
body: PageView.builder(
itemBuilder: (BuildContext context, int index){
return _pages[index];
},
controller: _pageController,
//控制可以滑动的数目
itemCount: _pages.length,
//与底部导航栏交互
onPageChanged: (index) {
setState(() {
_currentIndex = index;
});
},
),
/**
- 底部导航栏
*/
bottomNavigationBar: BottomNavigationBar(
//更新当前的条目
currentIndex: _currentIndex,
type: BottomNavigationBarType.fixed,
items: _navigationIconView.map((e) => e.item).toList(),
onTap: (index) {
setState(() {
_currentIndex = index;
});
//底部导航栏的滑动
_pageController.animateToPage(
index, duration: Duration(microseconds: 10), curve: Curves.ease);
},
),
drawer: MyDrawer(
headImgPath: ‘assets/images/cover_img.jpg’,
menuIcons: [Icons.send, Icons.home, Icons.error, Icons.settings],
menuTitles: [‘send’, ‘motivation’, ‘about’, ‘settings’],
),
);
}
}
my_drawer.dart自定义的Drawer,有构造函数和初始化的赋值
import ‘package:flutter/material.dart’;
import ‘file:///D:/Code/Flutter/FlutterHello/flutter_app2/flutter_app2/lib/