Rodrigo Lopez Peker

Navigation docs

- Added a Navigation. methods references in docs, for easier understanding of the names.
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter/scheduler.dart'; 2 import 'package:flutter/scheduler.dart';
3 -import 'package:get/src/core/get_interface.dart';  
4 import 'package:get/instance_manager.dart'; 3 import 'package:get/instance_manager.dart';
5 import 'package:get/route_manager.dart'; 4 import 'package:get/route_manager.dart';
  5 +import 'package:get/src/core/get_interface.dart';
6 import 'package:get/src/core/log.dart'; 6 import 'package:get/src/core/log.dart';
  7 +
7 import 'dialog/dialog_route.dart'; 8 import 'dialog/dialog_route.dart';
8 import 'root/parse_route.dart'; 9 import 'root/parse_route.dart';
9 import 'routes/bindings_interface.dart'; 10 import 'routes/bindings_interface.dart';
@@ -13,6 +14,8 @@ import 'routes/bindings_interface.dart'; @@ -13,6 +14,8 @@ import 'routes/bindings_interface.dart';
13 NavigatorState get navigator => Get.key.currentState; 14 NavigatorState get navigator => Get.key.currentState;
14 15
15 extension GetNavigation on GetInterface { 16 extension GetNavigation on GetInterface {
  17 + /// **Navigation.push()** shortcut.<br><br>
  18 + ///
16 /// Pushes a new [page] to the stack 19 /// Pushes a new [page] to the stack
17 /// 20 ///
18 /// It has the advantage of not needing context, 21 /// It has the advantage of not needing context,
@@ -69,7 +72,9 @@ extension GetNavigation on GetInterface { @@ -69,7 +72,9 @@ extension GetNavigation on GetInterface {
69 ); 72 );
70 } 73 }
71 74
72 - /// Pushes a new named [page] to the stack 75 + /// **Navigation.pushNamed()** shortcut.<br><br>
  76 + ///
  77 + /// Pushes a new named [page] to the stack.
73 /// 78 ///
74 /// It has the advantage of not needing context, so you can call 79 /// It has the advantage of not needing context, so you can call
75 /// from your business logic. 80 /// from your business logic.
@@ -95,6 +100,8 @@ extension GetNavigation on GetInterface { @@ -95,6 +100,8 @@ extension GetNavigation on GetInterface {
95 return global(id).currentState.pushNamed(page, arguments: arguments); 100 return global(id).currentState.pushNamed(page, arguments: arguments);
96 } 101 }
97 102
  103 + /// **Navigation.pushReplacementNamed()** shortcut.<br><br>
  104 + ///
98 /// Pop the current named [page] in the stack and push a new one in its place 105 /// Pop the current named [page] in the stack and push a new one in its place
99 /// 106 ///
100 /// It has the advantage of not needing context, so you can call 107 /// It has the advantage of not needing context, so you can call
@@ -123,6 +130,8 @@ extension GetNavigation on GetInterface { @@ -123,6 +130,8 @@ extension GetNavigation on GetInterface {
123 .pushReplacementNamed(page, arguments: arguments); 130 .pushReplacementNamed(page, arguments: arguments);
124 } 131 }
125 132
  133 + /// **Navigation.popUntil()** shortcut.<br><br>
  134 + ///
126 /// Calls pop several times in the stack until [predicate] returns true 135 /// Calls pop several times in the stack until [predicate] returns true
127 /// 136 ///
128 /// [id] is for when you are using nested navigation, 137 /// [id] is for when you are using nested navigation,
@@ -139,6 +148,8 @@ extension GetNavigation on GetInterface { @@ -139,6 +148,8 @@ extension GetNavigation on GetInterface {
139 return global(id).currentState.popUntil(predicate); 148 return global(id).currentState.popUntil(predicate);
140 } 149 }
141 150
  151 + /// **Navigation.pushAndRemoveUntil()** shortcut.<br><br>
  152 + ///
142 /// Push the given [page], and then pop several pages in the stack until 153 /// Push the given [page], and then pop several pages in the stack until
143 /// [predicate] returns true 154 /// [predicate] returns true
144 /// 155 ///
@@ -160,6 +171,8 @@ extension GetNavigation on GetInterface { @@ -160,6 +171,8 @@ extension GetNavigation on GetInterface {
160 return global(id).currentState.pushAndRemoveUntil(page, predicate); 171 return global(id).currentState.pushAndRemoveUntil(page, predicate);
161 } 172 }
162 173
  174 + /// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br>
  175 + ///
163 /// Push the given named [page], and then pop several pages in the stack 176 /// Push the given named [page], and then pop several pages in the stack
164 /// until [predicate] returns true 177 /// until [predicate] returns true
165 /// 178 ///
@@ -185,6 +198,8 @@ extension GetNavigation on GetInterface { @@ -185,6 +198,8 @@ extension GetNavigation on GetInterface {
185 .pushNamedAndRemoveUntil(page, predicate, arguments: arguments); 198 .pushNamedAndRemoveUntil(page, predicate, arguments: arguments);
186 } 199 }
187 200
  201 + /// **Navigation.popAndPushNamed()** shortcut.<br><br>
  202 + ///
188 /// Pop the current named page and pushes a new [page] to the stack in its place 203 /// Pop the current named page and pushes a new [page] to the stack in its place
189 /// 204 ///
190 /// You can send any type of value to the other route in the [arguments]. 205 /// You can send any type of value to the other route in the [arguments].
@@ -200,6 +215,8 @@ extension GetNavigation on GetInterface { @@ -200,6 +215,8 @@ extension GetNavigation on GetInterface {
200 .popAndPushNamed(page, arguments: arguments, result: result); 215 .popAndPushNamed(page, arguments: arguments, result: result);
201 } 216 }
202 217
  218 + /// **Navigation.removeRoute()** shortcut.<br><br>
  219 + ///
203 /// Remove a specific [route] from the stack 220 /// Remove a specific [route] from the stack
204 /// 221 ///
205 /// [id] is for when you are using nested navigation, 222 /// [id] is for when you are using nested navigation,
@@ -208,6 +225,8 @@ extension GetNavigation on GetInterface { @@ -208,6 +225,8 @@ extension GetNavigation on GetInterface {
208 return global(id).currentState.removeRoute(route); 225 return global(id).currentState.removeRoute(route);
209 } 226 }
210 227
  228 + /// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br>
  229 + ///
211 /// Push a named [page] and pop several pages in the stack 230 /// Push a named [page] and pop several pages in the stack
212 /// until [predicate] returns true. [predicate] is optional 231 /// until [predicate] returns true. [predicate] is optional
213 /// 232 ///
@@ -234,14 +253,16 @@ extension GetNavigation on GetInterface { @@ -234,14 +253,16 @@ extension GetNavigation on GetInterface {
234 arguments: arguments); 253 arguments: arguments);
235 } 254 }
236 255
237 - /// Returns true if a snackbar, dialog or bottomsheet is currently showing in the screen 256 + /// Returns true if a Snackbar, Dialog or BottomSheet is currently showing
238 bool get isOverlaysOpen => 257 bool get isOverlaysOpen =>
239 (isSnackbarOpen || isDialogOpen || isBottomSheetOpen); 258 (isSnackbarOpen || isDialogOpen || isBottomSheetOpen);
240 259
241 - /// returns true if there is no snackbar, dialog or bottomsheet open 260 + /// Returns true if there is no Snackbar, Dialog or BottomSheet open
242 bool get isOverlaysClosed => 261 bool get isOverlaysClosed =>
243 (!isSnackbarOpen && !isDialogOpen && !isBottomSheetOpen); 262 (!isSnackbarOpen && !isDialogOpen && !isBottomSheetOpen);
244 263
  264 + /// **Navigation.popUntil()** shortcut.<br><br>
  265 + ///
245 /// Pop the current page, snackbar, dialog or bottomsheet in the stack 266 /// Pop the current page, snackbar, dialog or bottomsheet in the stack
246 /// 267 ///
247 /// if your set [closeOverlays] to true, Get.back() will close the currently open 268 /// if your set [closeOverlays] to true, Get.back() will close the currently open
@@ -272,6 +293,8 @@ extension GetNavigation on GetInterface { @@ -272,6 +293,8 @@ extension GetNavigation on GetInterface {
272 } 293 }
273 } 294 }
274 295
  296 + /// **Navigation.popUntil()** (with predicate) shortcut .<br><br>
  297 + ///
275 /// Close as many routes as defined by [times] 298 /// Close as many routes as defined by [times]
276 /// 299 ///
277 /// [id] is for when you are using nested navigation, 300 /// [id] is for when you are using nested navigation,
@@ -287,6 +310,8 @@ extension GetNavigation on GetInterface { @@ -287,6 +310,8 @@ extension GetNavigation on GetInterface {
287 return back; 310 return back;
288 } 311 }
289 312
  313 + /// **Navigation.pushReplacement()** shortcut .<br><br>
  314 + ///
290 /// Pop the current page and pushes a new [page] to the stack 315 /// Pop the current page and pushes a new [page] to the stack
291 /// 316 ///
292 /// It has the advantage of not needing context, 317 /// It has the advantage of not needing context,
@@ -337,6 +362,8 @@ extension GetNavigation on GetInterface { @@ -337,6 +362,8 @@ extension GetNavigation on GetInterface {
337 transitionDuration: duration ?? defaultDurationTransition)); 362 transitionDuration: duration ?? defaultDurationTransition));
338 } 363 }
339 364
  365 + /// **Navigation.pushAndRemoveUntil()** shortcut .<br><br>
  366 + ///
340 /// Push a [page] and pop several pages in the stack 367 /// Push a [page] and pop several pages in the stack
341 /// until [predicate] returns true. [predicate] is optional 368 /// until [predicate] returns true. [predicate] is optional
342 /// 369 ///
@@ -470,6 +497,7 @@ extension GetNavigation on GetInterface { @@ -470,6 +497,7 @@ extension GetNavigation on GetInterface {
470 )); 497 ));
471 } 498 }
472 499
  500 + /// Custom UI Dialog.
473 Future<T> defaultDialog<T>({ 501 Future<T> defaultDialog<T>({
474 String title = "Alert", 502 String title = "Alert",
475 Widget content, 503 Widget content,
@@ -884,7 +912,7 @@ extension GetNavigation on GetInterface { @@ -884,7 +912,7 @@ extension GetNavigation on GetInterface {
884 return key; 912 return key;
885 } 913 }
886 if (!keys.containsKey(k)) { 914 if (!keys.containsKey(k)) {
887 - throw 'route id not found'; 915 + throw 'Route id ($k) not found';
888 } 916 }
889 return keys[k]; 917 return keys[k];
890 } 918 }
@@ -892,7 +920,7 @@ extension GetNavigation on GetInterface { @@ -892,7 +920,7 @@ extension GetNavigation on GetInterface {
892 RouteSettings get routeSettings => settings; 920 RouteSettings get routeSettings => settings;
893 921
894 void setSettings(RouteSettings settings) { 922 void setSettings(RouteSettings settings) {
895 - settings = settings; 923 + this.settings = settings;
896 } 924 }
897 925
898 /// give current arguments 926 /// give current arguments