flutter的手机桌面返回,FlutterActivity的方法变更
import 'package:an_chang_app/src/pages/work/order_add_page.dart';
import 'package:flutter/';
import 'package:flutter/';
import 'package:an_chang_app/src/pages/home/home_item3_page.dart';
import 'package:an_chang_app/src/pages/home/home_item_page.dart';
import 'pages/mine/mine_main_page.dart';
import 'utils/android_back_desktop.dart';
///首页面
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
//当前选中的标识
int _currentIndex = 0;
PageController _pageController = new PageController();
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: AndroidBackDesktop.backToDesktop,
child: Scaffold(
body: Container(
width: double.infinity,
height: double.infinity,
child: PageView(
controller: _pageController,
//不可左右滑动
physics: NeverScrollableScrollPhysics(),
children: [
//第四个文章列表页面
HomeItem3Page(),
//第五个个人中心页面
MineMainPage(),
],
),
),
bottomNavigationBar: BottomNavigationBar(
//当前选中的Item 默认为 0
currentIndex: _currentIndex,
//点击回调
onTap: (int value) {
setState(() {
_currentIndex = value;
_pageController.jumpToPage(value);
});
},
//显示文字
type: BottomNavigationBarType.fixed,
//选中的颜色
selectedItemColor: Colors.redAccent,
//未选中颜色
unselectedItemColor: Colors.blueGrey,
items: [
BottomNavigationBarItem(icon: Icon(Icons.message), label: "工单"),
BottomNavigationBarItem(icon: Icon(Icons.person), label: "我的"),
],
),
),
);
}
}