浏览代码

add FluroRouter.pop result

lukepighetti 5 年之前
父节点
当前提交
157fca6c68
共有 3 个文件被更改,包括 10 次插入3 次删除
  1. 4 1
      example/lib/components/demo/demo_simple_component.dart
  2. 2 1
      lib/src/fluro_router.dart
  3. 4 1
      lib/src/router.dart

+ 4 - 1
example/lib/components/demo/demo_simple_component.dart

@@ -8,6 +8,7 @@
  */
 import '../../helpers/color_helpers.dart';
 import 'package:flutter/material.dart';
+import 'package:fluro/fluro.dart';
 
 class DemoSimpleComponent extends StatelessWidget {
   DemoSimpleComponent(
@@ -56,9 +57,11 @@ class DemoSimpleComponent extends StatelessWidget {
                     ColorHelpers.blackOrWhiteContrastColor(color).withAlpha(34),
                 onPressed: () {
                   if (result == null) {
+                    /// You can use [Navigator.pop]
                     Navigator.pop(context);
                   } else {
-                    Navigator.pop(context, result);
+                    /// Or [FluroRouter.pop]
+                    FluroRouter.appRouter.pop(context, result);
                   }
                 },
                 child: Text(

+ 2 - 1
lib/src/fluro_router.dart

@@ -38,7 +38,8 @@ class FluroRouter {
     return _routeTree.matchRoute(path);
   }
 
-  void pop(BuildContext context) => Navigator.pop(context);
+  void pop<T>(BuildContext context, [T result]) =>
+      Navigator.pop(context, result);
 
   ///
   Future navigateTo(BuildContext context, String path,

+ 4 - 1
lib/src/router.dart

@@ -19,6 +19,8 @@ import 'package:flutter/material.dart' as material;
 /// Flutter's new [material.Router] class from the Pages / Navigator 2.0 API.
 ///
 /// [FluroRouter] is identical to [Router].
+///
+/// This will no longer be updated after version `1.6.4`.
 @Deprecated('Use FluroRouter instead')
 class Router {
   static final appRouter = Router();
@@ -43,7 +45,8 @@ class Router {
     return _routeTree.matchRoute(path);
   }
 
-  void pop(BuildContext context) => Navigator.pop(context);
+  void pop<T>(BuildContext context, [T result]) =>
+      Navigator.pop(context, result);
 
   ///
   Future navigateTo(BuildContext context, String path,