右滑返回上一页

代码:

import 'package:flutter/cupertino.dart';

class RightBackDemo extends StatelessWidget {
const RightBackDemo({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
child: Center(
child: Container(
height: 100.0,
width: 100.0,
color: CupertinoColors.activeBlue,
child: CupertinoButton(
child: Icon(CupertinoIcons.add),
onPressed: (){
Navigator.of(context).push(
CupertinoPageRoute(builder: (BuildContext context){//使用cupertinoPage 就自动带有手势右滑返回
return RightBackDemo();//还是打开本控件
})
);
},
),
),
),
);
}
}
总结:

//手势右滑返回操作

 

导入cupertino

使用的一切控件 都带前缀 cupertino  

使用CupertinoPageRoute()//系统会默认给我们添加右滑返回

 

猜你喜欢

转载自www.cnblogs.com/pp-pping/p/12214721.html
今日推荐