TargetPlatform.android如何实现侧滑关闭页面?

How to implement a side-slide close page on the TargetPlatform.android?

颤动设置TargetPlatform.iOS

new MaterialApp(
  title: 'Mian',
  theme: new ThemeData(
    primarySwatch: Colors.orange,
    platform: TargetPlatform.iOS,
  )
)

可以跳过关闭页面。

颤动设置TargetPlatform.android

new MaterialApp(
  title: 'Mian',
  theme: new ThemeData(
    primarySwatch: Colors.orange,
    platform: TargetPlatform.android,
  )
)

无法跳过关闭页面

您可以在按下 Widget 时使用 CupertinoPageRoute 来完成。

首先你必须导入 cupertino:

import 'package:flutter/cupertino.dart';

然后使用Navigator

Navigator.of(context)
            .push(CupertinoPageRoute(builder: (context) => YourNewWidgetPage()));

看文章有新答案更新,这种方式比较友好

enter code class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
  title: 'Flutter Demo',
  theme: ThemeData(
      primarySwatch: Colors.blue,
      pageTransitionsTheme: PageTransitionsTheme(builders: {
        TargetPlatform.android: CupertinoPageTransitionsBuilder(),
        TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
      })),
  routes: {
    "/": (BuildContext context) =>
        MyHomePage(title: 'Flutter Demo Home Page'),
    "/two": (BuildContext context) => TwoPage(),
  },
);
}
}

感谢 Arvinth 的文章:https://medium.com/flutter-community/page-transitions-using-themedata-in-flutter-c24afadb0b5d