flutter 右滑返回上一页
import 'package:flutter/material.dart'; import 'package:flutter_app/pages/SplashScreen.dart'; import 'right_back_demo.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.green, //定义主题风格 primarySwatch ), home: RightBackDemo(), ); } }
import 'package:flutter/cupertino.dart'; import 'MyHomePage.dart'; class RightBackDemo extends StatelessWidget { @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){ return MyHomePage(); }) ); }, ), ), ), ); } }
即可
最后,关注【码上加油站】微信公众号后,有疑惑有问题想加油的小伙伴可以码上加入社群,让我们一起码上加油吧!!!