Kaynağa Gözat

add pop convenience. add clearStack to clear history when pushing.

Luke Freeman 7 yıl önce
ebeveyn
işleme
a1de0f6283
4 değiştirilmiş dosya ile 18 ekleme ve 8 silme
  1. 4 0
      CHANGELOG.md
  2. 2 2
      README.md
  3. 10 4
      lib/src/router.dart
  4. 2 2
      pubspec.yaml

+ 4 - 0
CHANGELOG.md

@@ -1,3 +1,7 @@
+# 1.3.5
+- add `pop` convenience
+- add `clearStack` flag so that you can clear the history when pushing a route
+
 # 1.3.4
 # 1.3.4
 - Change lower dart version to cater to older flutter versions
 - Change lower dart version to cater to older flutter versions
 
 

+ 2 - 2
README.md

@@ -3,7 +3,7 @@
 
 
 The brightest, hippest, coolest router for Flutter.
 The brightest, hippest, coolest router for Flutter.
 
 
-[![Version](https://img.shields.io/badge/version-1.3.4-blue.svg)](https://pub.dartlang.org/packages/fluro)
+[![Version](https://img.shields.io/badge/version-1.3.5-blue.svg)](https://pub.dartlang.org/packages/fluro)
 [![Build Status](https://travis-ci.org/theyakka/fluro.svg?branch=master)](https://travis-ci.org/theyakka/fluro)
 [![Build Status](https://travis-ci.org/theyakka/fluro.svg?branch=master)](https://travis-ci.org/theyakka/fluro)
 [![Coverage](https://codecov.io/gh/theyakka/fluro/branch/master/graph/badge.svg)](https://codecov.io/gh/theyakka/fluro)
 [![Coverage](https://codecov.io/gh/theyakka/fluro/branch/master/graph/badge.svg)](https://codecov.io/gh/theyakka/fluro)
 
 
@@ -25,7 +25,7 @@ See CHANGELOG for all breaking (and non-breaking) changes.
 You should ensure that you add the router as a dependency in your flutter project.
 You should ensure that you add the router as a dependency in your flutter project.
 ```yaml
 ```yaml
 dependencies:
 dependencies:
- fluro: "^1.3.4"
+ fluro: "^1.3.5"
 ```
 ```
 
 
 You can also reference the git repo directly if you want:
 You can also reference the git repo directly if you want:

+ 10 - 4
lib/src/router.dart

@@ -43,9 +43,11 @@ class Router {
     return _routeTree.matchRoute(path);
     return _routeTree.matchRoute(path);
   }
   }
 
 
+  bool pop(BuildContext context) => Navigator.pop(context);
+
   ///
   ///
   Future navigateTo(BuildContext context, String path,
   Future navigateTo(BuildContext context, String path,
-      {bool replace = false,
+      {bool replace = false, bool clearStack = false,
       TransitionType transition = TransitionType.native,
       TransitionType transition = TransitionType.native,
       Duration transitionDuration = const Duration(milliseconds: 250),
       Duration transitionDuration = const Duration(milliseconds: 250),
       RouteTransitionsBuilder transitionBuilder}) {
       RouteTransitionsBuilder transitionBuilder}) {
@@ -63,9 +65,13 @@ class Router {
         route = _notFoundRoute(context, path);
         route = _notFoundRoute(context, path);
       }
       }
       if (route != null) {
       if (route != null) {
-        future = replace
-            ? Navigator.pushReplacement(context, route)
-            : Navigator.push(context, route);
+        if (clearStack) {
+          future = Navigator.pushAndRemoveUntil(context, route, (check) => false);
+        } else {
+          future = replace
+              ? Navigator.pushReplacement(context, route)
+              : Navigator.push(context, route);
+        }
         completer.complete();
         completer.complete();
       } else {
       } else {
         String error = "No registered route was found to handle '$path'.";
         String error = "No registered route was found to handle '$path'.";

+ 2 - 2
pubspec.yaml

@@ -2,7 +2,7 @@ name: fluro
 description: >
 description: >
   Fluro is a Flutter routing library that adds flexible routing options like wildcards, named
   Fluro is a Flutter routing library that adds flexible routing options like wildcards, named
   parameters and clear route definitions.
   parameters and clear route definitions.
-version: 1.3.4
+version: 1.3.5
 author: Yakka, LLC <flutter@theyakka.com>
 author: Yakka, LLC <flutter@theyakka.com>
 homepage: https://github.com/theyakka/fluro
 homepage: https://github.com/theyakka/fluro
 
 
@@ -16,7 +16,7 @@ dependencies:
 dev_dependencies:
 dev_dependencies:
   flutter_test:
   flutter_test:
     sdk: flutter
     sdk: flutter
-  test: ">=0.12.30+3 <0.13.0"
+  test: "^1.3.3"
 
 
 flutter:
 flutter:
   uses-material-design: false
   uses-material-design: false