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

This commit is contained in:
Luke Freeman 2018-10-08 16:31:10 -07:00
parent c51031e6e3
commit a1de0f6283
4 changed files with 18 additions and 8 deletions

View File

@ -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
- Change lower dart version to cater to older flutter versions

View File

@ -3,7 +3,7 @@
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)
[![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.
```yaml
dependencies:
fluro: "^1.3.4"
fluro: "^1.3.5"
```
You can also reference the git repo directly if you want:

View File

@ -43,9 +43,11 @@ class Router {
return _routeTree.matchRoute(path);
}
bool pop(BuildContext context) => Navigator.pop(context);
///
Future navigateTo(BuildContext context, String path,
{bool replace = false,
{bool replace = false, bool clearStack = false,
TransitionType transition = TransitionType.native,
Duration transitionDuration = const Duration(milliseconds: 250),
RouteTransitionsBuilder transitionBuilder}) {
@ -63,9 +65,13 @@ class Router {
route = _notFoundRoute(context, path);
}
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();
} else {
String error = "No registered route was found to handle '$path'.";

View File

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