Showing
10 changed files
with
650 additions
and
3 deletions
CHANGELOG.md
0 → 100644
| 1 | MIT License | 1 | MIT License |
| 2 | 2 | ||
| 3 | -Copyright (c) 2019 jonataslaw | 3 | +Copyright (c) 2019 Jonny Borges |
| 4 | 4 | ||
| 5 | Permission is hereby granted, free of charge, to any person obtaining a copy | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | of this software and associated documentation files (the "Software"), to deal | 6 | of this software and associated documentation files (the "Software"), to deal |
| @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | -SOFTWARE. | 21 | +SOFTWARE. |
| 1 | -# get | 1 | +# Get |
| 2 | + | ||
| 2 | A consistent Flutter route navigation library that does not rebuild materialApp with each navigation. | 3 | A consistent Flutter route navigation library that does not rebuild materialApp with each navigation. |
| 4 | + | ||
| 5 | +## Getting Started | ||
| 6 | + | ||
| 7 | +Flutter's conventional navigation method has a route reconstruction bug that makes it inconsistent | ||
| 8 | +for large applications with undefined routes. | ||
| 9 | +Get came to solve this problem. | ||
| 10 | + | ||
| 11 | +Plus, get makes navigation much clearer and more concise for beginners. The nomenclatures u | ||
| 12 | +sed by Flutter routes often confuse those who start with the framework. | ||
| 13 | +Get is friendly to those who came from Web programming, and those who never programmed, | ||
| 14 | +with a clearer navigation system. | ||
| 15 | + | ||
| 16 | +## How to use? | ||
| 17 | + | ||
| 18 | +To navigate to a new screen: | ||
| 19 | + | ||
| 20 | +```dart | ||
| 21 | +Get.to(context, NextScreen()); | ||
| 22 | +``` | ||
| 23 | + | ||
| 24 | +To return to previous screen | ||
| 25 | + | ||
| 26 | +```dart | ||
| 27 | +Get.back(context); | ||
| 28 | +``` | ||
| 29 | + | ||
| 30 | +To go to the next screen and no option to go back to the previous screen (for use in SplashScreens, login screens and etc.) | ||
| 31 | + | ||
| 32 | +```dart | ||
| 33 | +Get.off(context, NextScreen()); | ||
| 34 | +``` | ||
| 35 | + | ||
| 36 | +To go to the next screen and cancel all previous routes (useful in shopping carts, polls, and tests) | ||
| 37 | + | ||
| 38 | +```dart | ||
| 39 | +Get.offAll(context, NextScreen()); | ||
| 40 | +``` | ||
| 41 | + | ||
| 42 | +Is possible used default namedRoutes from flutter? | ||
| 43 | +Yes, and with no navigation bug | ||
| 44 | +Example: | ||
| 45 | + | ||
| 46 | +```dart | ||
| 47 | +void main() { | ||
| 48 | + runApp(MaterialApp( | ||
| 49 | + onGenerateRoute: Router.generateRoute, | ||
| 50 | + initialRoute: "/", | ||
| 51 | + title: 'Navigation', | ||
| 52 | + )); | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +class Router { | ||
| 56 | + static Route<dynamic> generateRoute(RouteSettings settings) { | ||
| 57 | + switch (settings.name) { | ||
| 58 | + case '/': | ||
| 59 | + return GetRoute(builder: (_) => FirstRoute()); | ||
| 60 | + case '/second': | ||
| 61 | + return GetRoute(builder: (_) => SecondRoute()); | ||
| 62 | + default: | ||
| 63 | + return GetRoute( | ||
| 64 | + builder: (_) => Scaffold( | ||
| 65 | + body: Center( | ||
| 66 | + child: Text('No route defined for ${settings.name}')), | ||
| 67 | + )); | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | +} | ||
| 71 | + | ||
| 72 | +class FirstRoute extends StatelessWidget { | ||
| 73 | + @override | ||
| 74 | + Widget build(BuildContext context) { | ||
| 75 | + return Scaffold( | ||
| 76 | + appBar: AppBar( | ||
| 77 | + title: Text('First Route'), | ||
| 78 | + ), | ||
| 79 | + body: Center( | ||
| 80 | + child: RaisedButton( | ||
| 81 | + child: Text('Open route'), | ||
| 82 | + onPressed: () { | ||
| 83 | + Navigator.pushNamed(context, "/second"); | ||
| 84 | + }, | ||
| 85 | + ), | ||
| 86 | + ), | ||
| 87 | + ); | ||
| 88 | + } | ||
| 89 | +} | ||
| 90 | + | ||
| 91 | +class SecondRoute extends StatelessWidget { | ||
| 92 | + @override | ||
| 93 | + Widget build(BuildContext context) { | ||
| 94 | + return Scaffold( | ||
| 95 | + appBar: AppBar( | ||
| 96 | + title: Text("Second Route"), | ||
| 97 | + ), | ||
| 98 | + body: Center( | ||
| 99 | + child: RaisedButton( | ||
| 100 | + onPressed: () { | ||
| 101 | + Get.back(context); | ||
| 102 | + }, | ||
| 103 | + child: Text('Go back!'), | ||
| 104 | + ), | ||
| 105 | + ), | ||
| 106 | + ); | ||
| 107 | + } | ||
| 108 | +} | ||
| 109 | +``` |
example/lib/main.dart
0 → 100644
| 1 | +import 'package:flutter/material.dart'; | ||
| 2 | +import 'package:get/get.dart'; | ||
| 3 | + | ||
| 4 | +void main() { | ||
| 5 | + runApp(MaterialApp( | ||
| 6 | + title: 'Navigation Basics', | ||
| 7 | + home: FirstRoute(), | ||
| 8 | + )); | ||
| 9 | +} | ||
| 10 | + | ||
| 11 | +class FirstRoute extends StatelessWidget { | ||
| 12 | + @override | ||
| 13 | + Widget build(BuildContext context) { | ||
| 14 | + return Scaffold( | ||
| 15 | + appBar: AppBar( | ||
| 16 | + title: Text('First Route'), | ||
| 17 | + ), | ||
| 18 | + body: Center( | ||
| 19 | + child: RaisedButton( | ||
| 20 | + child: Text('Open route'), | ||
| 21 | + onPressed: () { | ||
| 22 | + Get.to(context, SecondRoute()); | ||
| 23 | + }, | ||
| 24 | + ), | ||
| 25 | + ), | ||
| 26 | + ); | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +class SecondRoute extends StatelessWidget { | ||
| 31 | + @override | ||
| 32 | + Widget build(BuildContext context) { | ||
| 33 | + return Scaffold( | ||
| 34 | + appBar: AppBar( | ||
| 35 | + title: Text("Second Route"), | ||
| 36 | + ), | ||
| 37 | + body: Center( | ||
| 38 | + child: RaisedButton( | ||
| 39 | + onPressed: () { | ||
| 40 | + Get.back(context); | ||
| 41 | + }, | ||
| 42 | + child: Text('Go back!'), | ||
| 43 | + ), | ||
| 44 | + ), | ||
| 45 | + ); | ||
| 46 | + } | ||
| 47 | +} |
example/pubspec.lock
0 → 100644
| 1 | +# Generated by pub | ||
| 2 | +# See https://dart.dev/tools/pub/glossary#lockfile | ||
| 3 | +packages: | ||
| 4 | + archive: | ||
| 5 | + dependency: transitive | ||
| 6 | + description: | ||
| 7 | + name: archive | ||
| 8 | + url: "https://pub.dartlang.org" | ||
| 9 | + source: hosted | ||
| 10 | + version: "2.0.10" | ||
| 11 | + args: | ||
| 12 | + dependency: transitive | ||
| 13 | + description: | ||
| 14 | + name: args | ||
| 15 | + url: "https://pub.dartlang.org" | ||
| 16 | + source: hosted | ||
| 17 | + version: "1.5.2" | ||
| 18 | + async: | ||
| 19 | + dependency: transitive | ||
| 20 | + description: | ||
| 21 | + name: async | ||
| 22 | + url: "https://pub.dartlang.org" | ||
| 23 | + source: hosted | ||
| 24 | + version: "2.3.0" | ||
| 25 | + boolean_selector: | ||
| 26 | + dependency: transitive | ||
| 27 | + description: | ||
| 28 | + name: boolean_selector | ||
| 29 | + url: "https://pub.dartlang.org" | ||
| 30 | + source: hosted | ||
| 31 | + version: "1.0.5" | ||
| 32 | + charcode: | ||
| 33 | + dependency: transitive | ||
| 34 | + description: | ||
| 35 | + name: charcode | ||
| 36 | + url: "https://pub.dartlang.org" | ||
| 37 | + source: hosted | ||
| 38 | + version: "1.1.2" | ||
| 39 | + collection: | ||
| 40 | + dependency: transitive | ||
| 41 | + description: | ||
| 42 | + name: collection | ||
| 43 | + url: "https://pub.dartlang.org" | ||
| 44 | + source: hosted | ||
| 45 | + version: "1.14.11" | ||
| 46 | + convert: | ||
| 47 | + dependency: transitive | ||
| 48 | + description: | ||
| 49 | + name: convert | ||
| 50 | + url: "https://pub.dartlang.org" | ||
| 51 | + source: hosted | ||
| 52 | + version: "2.1.1" | ||
| 53 | + crypto: | ||
| 54 | + dependency: transitive | ||
| 55 | + description: | ||
| 56 | + name: crypto | ||
| 57 | + url: "https://pub.dartlang.org" | ||
| 58 | + source: hosted | ||
| 59 | + version: "2.1.3" | ||
| 60 | + cupertino_icons: | ||
| 61 | + dependency: "direct main" | ||
| 62 | + description: | ||
| 63 | + name: cupertino_icons | ||
| 64 | + url: "https://pub.dartlang.org" | ||
| 65 | + source: hosted | ||
| 66 | + version: "0.1.2" | ||
| 67 | + flutter: | ||
| 68 | + dependency: "direct main" | ||
| 69 | + description: flutter | ||
| 70 | + source: sdk | ||
| 71 | + version: "0.0.0" | ||
| 72 | + flutter_test: | ||
| 73 | + dependency: "direct dev" | ||
| 74 | + description: flutter | ||
| 75 | + source: sdk | ||
| 76 | + version: "0.0.0" | ||
| 77 | + get: | ||
| 78 | + dependency: "direct main" | ||
| 79 | + description: | ||
| 80 | + name: get | ||
| 81 | + url: "https://pub.dartlang.org" | ||
| 82 | + source: hosted | ||
| 83 | + version: "1.0.2" | ||
| 84 | + image: | ||
| 85 | + dependency: transitive | ||
| 86 | + description: | ||
| 87 | + name: image | ||
| 88 | + url: "https://pub.dartlang.org" | ||
| 89 | + source: hosted | ||
| 90 | + version: "2.1.4" | ||
| 91 | + matcher: | ||
| 92 | + dependency: transitive | ||
| 93 | + description: | ||
| 94 | + name: matcher | ||
| 95 | + url: "https://pub.dartlang.org" | ||
| 96 | + source: hosted | ||
| 97 | + version: "0.12.5" | ||
| 98 | + meta: | ||
| 99 | + dependency: transitive | ||
| 100 | + description: | ||
| 101 | + name: meta | ||
| 102 | + url: "https://pub.dartlang.org" | ||
| 103 | + source: hosted | ||
| 104 | + version: "1.1.7" | ||
| 105 | + path: | ||
| 106 | + dependency: transitive | ||
| 107 | + description: | ||
| 108 | + name: path | ||
| 109 | + url: "https://pub.dartlang.org" | ||
| 110 | + source: hosted | ||
| 111 | + version: "1.6.4" | ||
| 112 | + pedantic: | ||
| 113 | + dependency: transitive | ||
| 114 | + description: | ||
| 115 | + name: pedantic | ||
| 116 | + url: "https://pub.dartlang.org" | ||
| 117 | + source: hosted | ||
| 118 | + version: "1.8.0+1" | ||
| 119 | + petitparser: | ||
| 120 | + dependency: transitive | ||
| 121 | + description: | ||
| 122 | + name: petitparser | ||
| 123 | + url: "https://pub.dartlang.org" | ||
| 124 | + source: hosted | ||
| 125 | + version: "2.4.0" | ||
| 126 | + quiver: | ||
| 127 | + dependency: transitive | ||
| 128 | + description: | ||
| 129 | + name: quiver | ||
| 130 | + url: "https://pub.dartlang.org" | ||
| 131 | + source: hosted | ||
| 132 | + version: "2.0.5" | ||
| 133 | + sky_engine: | ||
| 134 | + dependency: transitive | ||
| 135 | + description: flutter | ||
| 136 | + source: sdk | ||
| 137 | + version: "0.0.99" | ||
| 138 | + source_span: | ||
| 139 | + dependency: transitive | ||
| 140 | + description: | ||
| 141 | + name: source_span | ||
| 142 | + url: "https://pub.dartlang.org" | ||
| 143 | + source: hosted | ||
| 144 | + version: "1.5.5" | ||
| 145 | + stack_trace: | ||
| 146 | + dependency: transitive | ||
| 147 | + description: | ||
| 148 | + name: stack_trace | ||
| 149 | + url: "https://pub.dartlang.org" | ||
| 150 | + source: hosted | ||
| 151 | + version: "1.9.3" | ||
| 152 | + stream_channel: | ||
| 153 | + dependency: transitive | ||
| 154 | + description: | ||
| 155 | + name: stream_channel | ||
| 156 | + url: "https://pub.dartlang.org" | ||
| 157 | + source: hosted | ||
| 158 | + version: "2.0.0" | ||
| 159 | + string_scanner: | ||
| 160 | + dependency: transitive | ||
| 161 | + description: | ||
| 162 | + name: string_scanner | ||
| 163 | + url: "https://pub.dartlang.org" | ||
| 164 | + source: hosted | ||
| 165 | + version: "1.0.5" | ||
| 166 | + term_glyph: | ||
| 167 | + dependency: transitive | ||
| 168 | + description: | ||
| 169 | + name: term_glyph | ||
| 170 | + url: "https://pub.dartlang.org" | ||
| 171 | + source: hosted | ||
| 172 | + version: "1.1.0" | ||
| 173 | + test_api: | ||
| 174 | + dependency: transitive | ||
| 175 | + description: | ||
| 176 | + name: test_api | ||
| 177 | + url: "https://pub.dartlang.org" | ||
| 178 | + source: hosted | ||
| 179 | + version: "0.2.5" | ||
| 180 | + typed_data: | ||
| 181 | + dependency: transitive | ||
| 182 | + description: | ||
| 183 | + name: typed_data | ||
| 184 | + url: "https://pub.dartlang.org" | ||
| 185 | + source: hosted | ||
| 186 | + version: "1.1.6" | ||
| 187 | + vector_math: | ||
| 188 | + dependency: transitive | ||
| 189 | + description: | ||
| 190 | + name: vector_math | ||
| 191 | + url: "https://pub.dartlang.org" | ||
| 192 | + source: hosted | ||
| 193 | + version: "2.0.8" | ||
| 194 | + xml: | ||
| 195 | + dependency: transitive | ||
| 196 | + description: | ||
| 197 | + name: xml | ||
| 198 | + url: "https://pub.dartlang.org" | ||
| 199 | + source: hosted | ||
| 200 | + version: "3.5.0" | ||
| 201 | +sdks: | ||
| 202 | + dart: ">=2.4.0 <3.0.0" |
example/pubspec.yaml
0 → 100644
| 1 | +name: profileweb | ||
| 2 | +description: A new Flutter project. | ||
| 3 | + | ||
| 4 | +# The following defines the version and build number for your application. | ||
| 5 | +# A version number is three numbers separated by dots, like 1.2.43 | ||
| 6 | +# followed by an optional build number separated by a +. | ||
| 7 | +# Both the version and the builder number may be overridden in flutter | ||
| 8 | +# build by specifying --build-name and --build-number, respectively. | ||
| 9 | +# In Android, build-name is used as versionName while build-number used as versionCode. | ||
| 10 | +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning | ||
| 11 | +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. | ||
| 12 | +# Read more about iOS versioning at | ||
| 13 | +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html | ||
| 14 | +version: 1.0.0+1 | ||
| 15 | + | ||
| 16 | +environment: | ||
| 17 | + sdk: ">=2.1.0 <3.0.0" | ||
| 18 | + | ||
| 19 | +dependencies: | ||
| 20 | + flutter: | ||
| 21 | + sdk: flutter | ||
| 22 | + | ||
| 23 | + # The following adds the Cupertino Icons font to your application. | ||
| 24 | + # Use with the CupertinoIcons class for iOS style icons. | ||
| 25 | + cupertino_icons: ^0.1.2 | ||
| 26 | + get: | ||
| 27 | + | ||
| 28 | +dev_dependencies: | ||
| 29 | + flutter_test: | ||
| 30 | + sdk: flutter | ||
| 31 | + | ||
| 32 | + | ||
| 33 | +# For information on the generic Dart part of this file, see the | ||
| 34 | +# following page: https://dart.dev/tools/pub/pubspec | ||
| 35 | + | ||
| 36 | +# The following section is specific to Flutter. | ||
| 37 | +flutter: | ||
| 38 | + | ||
| 39 | + # The following line ensures that the Material Icons font is | ||
| 40 | + # included with your application, so that you can use the icons in | ||
| 41 | + # the material Icons class. | ||
| 42 | + uses-material-design: true | ||
| 43 | + | ||
| 44 | + # To add assets to your application, add an assets section, like this: | ||
| 45 | + # assets: | ||
| 46 | + # - images/a_dot_burr.jpeg | ||
| 47 | + # - images/a_dot_ham.jpeg | ||
| 48 | + | ||
| 49 | + # An image asset can refer to one or more resolution-specific "variants", see | ||
| 50 | + # https://flutter.dev/assets-and-images/#resolution-aware. | ||
| 51 | + | ||
| 52 | + # For details regarding adding assets from package dependencies, see | ||
| 53 | + # https://flutter.dev/assets-and-images/#from-packages | ||
| 54 | + | ||
| 55 | + # To add custom fonts to your application, add a fonts section here, | ||
| 56 | + # in this "flutter" section. Each entry in this list should have a | ||
| 57 | + # "family" key with the font family name, and a "fonts" key with a | ||
| 58 | + # list giving the asset and other descriptors for the font. For | ||
| 59 | + # example: | ||
| 60 | + # fonts: | ||
| 61 | + # - family: Schyler | ||
| 62 | + # fonts: | ||
| 63 | + # - asset: fonts/Schyler-Regular.ttf | ||
| 64 | + # - asset: fonts/Schyler-Italic.ttf | ||
| 65 | + # style: italic | ||
| 66 | + # - family: Trajan Pro | ||
| 67 | + # fonts: | ||
| 68 | + # - asset: fonts/TrajanPro.ttf | ||
| 69 | + # - asset: fonts/TrajanPro_Bold.ttf | ||
| 70 | + # weight: 700 | ||
| 71 | + # | ||
| 72 | + # For details regarding fonts from package dependencies, | ||
| 73 | + # see https://flutter.dev/custom-fonts/#from-packages |
lib/get.dart
0 → 100644
lib/src/material.dart
0 → 100644
| 1 | +import 'package:flutter/cupertino.dart'; | ||
| 2 | +import 'package:flutter/material.dart'; | ||
| 3 | + | ||
| 4 | +/// A modal route that replaces the entire screen with a platform-adaptive | ||
| 5 | +/// transition. | ||
| 6 | +/// | ||
| 7 | +/// For Android, the entrance transition for the page slides the page upwards | ||
| 8 | +/// and fades it in. The exit transition is the same, but in reverse. | ||
| 9 | +/// | ||
| 10 | +/// The transition is adaptive to the platform and on iOS, the page slides in | ||
| 11 | +/// from the right and exits in reverse. The page also shifts to the left in | ||
| 12 | +/// parallax when another page enters to cover it. (These directions are flipped | ||
| 13 | +/// in environments with a right-to-left reading direction.) | ||
| 14 | +/// | ||
| 15 | +/// By default, when a modal route is replaced by another, the previous route | ||
| 16 | +/// remains in memory. To free all the resources when this is not necessary, set | ||
| 17 | +/// [maintainState] to false. | ||
| 18 | +/// | ||
| 19 | +/// The `fullscreenDialog` property specifies whether the incoming page is a | ||
| 20 | +/// fullscreen modal dialog. On iOS, those pages animate from the bottom to the | ||
| 21 | +/// top rather than horizontally. | ||
| 22 | +/// | ||
| 23 | +/// The type `T` specifies the return type of the route which can be supplied as | ||
| 24 | +/// the route is popped from the stack via [Navigator.pop] by providing the | ||
| 25 | +/// optional `result` argument. | ||
| 26 | +/// | ||
| 27 | +/// See also: | ||
| 28 | +/// | ||
| 29 | +/// * [PageTransitionsTheme], which defines the default page transitions used | ||
| 30 | +/// by [MaterialPageRoute.buildTransitions]. | ||
| 31 | +class GetRoute<T> extends PageRoute<T> { | ||
| 32 | + /// Construct a MaterialPageRoute whose contents are defined by [builder]. | ||
| 33 | + /// | ||
| 34 | + /// The values of [builder], [maintainState], and [fullScreenDialog] must not | ||
| 35 | + /// be null. | ||
| 36 | + GetRoute({ | ||
| 37 | + @required this.builder, | ||
| 38 | + RouteSettings settings, | ||
| 39 | + this.opaque = true, | ||
| 40 | + this.maintainState = true, | ||
| 41 | + bool fullscreenDialog = false, | ||
| 42 | + }) : assert(builder != null), | ||
| 43 | + assert(maintainState != null), | ||
| 44 | + assert(fullscreenDialog != null), | ||
| 45 | + assert(opaque != null), | ||
| 46 | + super(settings: settings, fullscreenDialog: fullscreenDialog); | ||
| 47 | + | ||
| 48 | + /// Builds the primary contents of the route. | ||
| 49 | + final WidgetBuilder builder; | ||
| 50 | + | ||
| 51 | + @override | ||
| 52 | + final bool maintainState; | ||
| 53 | + | ||
| 54 | + /// Allows you to set opaque to false to prevent route reconstruction. | ||
| 55 | + @override | ||
| 56 | + final bool opaque; | ||
| 57 | + | ||
| 58 | + @override | ||
| 59 | + Duration get transitionDuration => const Duration(milliseconds: 300); | ||
| 60 | + | ||
| 61 | + @override | ||
| 62 | + Color get barrierColor => null; | ||
| 63 | + | ||
| 64 | + @override | ||
| 65 | + String get barrierLabel => null; | ||
| 66 | + | ||
| 67 | + @override | ||
| 68 | + bool canTransitionFrom(TransitionRoute<dynamic> previousRoute) { | ||
| 69 | + return previousRoute is GetRoute || previousRoute is CupertinoPageRoute; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @override | ||
| 73 | + bool canTransitionTo(TransitionRoute<dynamic> nextRoute) { | ||
| 74 | + // Don't perform outgoing animation if the next route is a fullscreen dialog. | ||
| 75 | + return (nextRoute is GetRoute && !nextRoute.fullscreenDialog) | ||
| 76 | + || (nextRoute is CupertinoPageRoute && !nextRoute.fullscreenDialog); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @override | ||
| 80 | + Widget buildPage( | ||
| 81 | + BuildContext context, | ||
| 82 | + Animation<double> animation, | ||
| 83 | + Animation<double> secondaryAnimation, | ||
| 84 | + ) { | ||
| 85 | + final Widget result = builder(context); | ||
| 86 | + assert(() { | ||
| 87 | + if (result == null) { | ||
| 88 | + throw FlutterError.fromParts(<DiagnosticsNode>[ | ||
| 89 | + ErrorSummary('The builder for route "${settings.name}" returned null.'), | ||
| 90 | + ErrorDescription('Route builders must never return null.') | ||
| 91 | + ]); | ||
| 92 | + } | ||
| 93 | + return true; | ||
| 94 | + }()); | ||
| 95 | + return Semantics( | ||
| 96 | + scopesRoute: true, | ||
| 97 | + explicitChildNodes: true, | ||
| 98 | + child: result, | ||
| 99 | + ); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + @override | ||
| 103 | + Widget buildTransitions(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) { | ||
| 104 | + final PageTransitionsTheme theme = Theme.of(context).pageTransitionsTheme; | ||
| 105 | + return theme.buildTransitions<T>(this, context, animation, secondaryAnimation, child); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @override | ||
| 109 | + String get debugLabel => '${super.debugLabel}(${settings.name})'; | ||
| 110 | +} |
lib/src/routes.dart
0 → 100644
| 1 | +import 'package:flutter/widgets.dart'; | ||
| 2 | +import 'material.dart'; | ||
| 3 | + | ||
| 4 | +class Get { | ||
| 5 | + static to(BuildContext context, Widget page, {bool rebuildRoutes = false}) { | ||
| 6 | + return Navigator.push( | ||
| 7 | + context, | ||
| 8 | + GetRoute( | ||
| 9 | + opaque: rebuildRoutes, builder: (BuildContext context) => page)); | ||
| 10 | + } | ||
| 11 | + | ||
| 12 | + static back(BuildContext context) { | ||
| 13 | + return Navigator.pop(context); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + static off(BuildContext context, Widget page, {bool rebuildRoutes = false}) { | ||
| 17 | + return Navigator.pushReplacement( | ||
| 18 | + context, | ||
| 19 | + GetRoute( | ||
| 20 | + opaque: rebuildRoutes, builder: (BuildContext context) => page)); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + static offAll(BuildContext context, Widget page, RoutePredicate predicate, | ||
| 24 | + {bool rebuildRoutes = false}) { | ||
| 25 | + return Navigator.pushAndRemoveUntil( | ||
| 26 | + context, | ||
| 27 | + GetRoute( | ||
| 28 | + opaque: rebuildRoutes, builder: (BuildContext context) => page), | ||
| 29 | + predicate); | ||
| 30 | + } | ||
| 31 | +} |
pubspec.yaml
0 → 100644
| 1 | +name: get | ||
| 2 | +description: A consistent Flutter route navigation library that does not rebuild materialApp with each navigation.. | ||
| 3 | +version: 1.1.0 | ||
| 4 | +author: Jonny Borges <jonataborges01@gmail.com> | ||
| 5 | +homepage: https://github.com/jonataslaw/get | ||
| 6 | + | ||
| 7 | +environment: | ||
| 8 | + sdk: ">=2.1.0 <3.0.0" | ||
| 9 | + | ||
| 10 | +dependencies: | ||
| 11 | + flutter: | ||
| 12 | + sdk: flutter | ||
| 13 | + | ||
| 14 | +dev_dependencies: | ||
| 15 | + flutter_test: | ||
| 16 | + sdk: flutter | ||
| 17 | + | ||
| 18 | +# For information on the generic Dart part of this file, see the | ||
| 19 | +# following page: https://dart.dev/tools/pub/pubspec | ||
| 20 | + | ||
| 21 | +# The following section is specific to Flutter. | ||
| 22 | +flutter: | ||
| 23 | + | ||
| 24 | + # To add assets to your package, add an assets section, like this: | ||
| 25 | + # assets: | ||
| 26 | + # - images/a_dot_burr.jpeg | ||
| 27 | + # - images/a_dot_ham.jpeg | ||
| 28 | + # | ||
| 29 | + # For details regarding assets in packages, see | ||
| 30 | + # https://flutter.dev/assets-and-images/#from-packages | ||
| 31 | + # | ||
| 32 | + # An image asset can refer to one or more resolution-specific "variants", see | ||
| 33 | + # https://flutter.dev/assets-and-images/#resolution-aware. | ||
| 34 | + | ||
| 35 | + # To add custom fonts to your package, add a fonts section here, | ||
| 36 | + # in this "flutter" section. Each entry in this list should have a | ||
| 37 | + # "family" key with the font family name, and a "fonts" key with a | ||
| 38 | + # list giving the asset and other descriptors for the font. For | ||
| 39 | + # example: | ||
| 40 | + # fonts: | ||
| 41 | + # - family: Schyler | ||
| 42 | + # fonts: | ||
| 43 | + # - asset: fonts/Schyler-Regular.ttf | ||
| 44 | + # - asset: fonts/Schyler-Italic.ttf | ||
| 45 | + # style: italic | ||
| 46 | + # - family: Trajan Pro | ||
| 47 | + # fonts: | ||
| 48 | + # - asset: fonts/TrajanPro.ttf | ||
| 49 | + # - asset: fonts/TrajanPro_Bold.ttf | ||
| 50 | + # weight: 700 | ||
| 51 | + # | ||
| 52 | + # For details regarding fonts in packages, see | ||
| 53 | + # https://flutter.dev/custom-fonts/#from-packages |
-
Please register or login to post a comment