Jonny Borges
Committed by GitHub

Merge pull request #581 from justkawal/master

Minor Code Reduction without affecting functionality
1 part of 'app_pages.dart'; 1 part of 'app_pages.dart';
2 2
3 -abstract class Routes{  
4 - 3 +abstract class Routes {
5 static const HOME = '/home'; 4 static const HOME = '/home';
6 static const COUNTRY = '/country'; 5 static const COUNTRY = '/country';
7 static const DETAILS = '/details'; 6 static const DETAILS = '/details';
@@ -261,4 +261,3 @@ class GetMaterialApp extends StatelessWidget { @@ -261,4 +261,3 @@ class GetMaterialApp extends StatelessWidget {
261 abstract class Translations { 261 abstract class Translations {
262 Map<String, Map<String, String>> get keys; 262 Map<String, Map<String, String>> get keys;
263 } 263 }
264 -  
@@ -85,21 +85,14 @@ class GetPageRoute<T> extends PageRoute<T> { @@ -85,21 +85,14 @@ class GetPageRoute<T> extends PageRoute<T> {
85 } 85 }
86 86
87 static bool _isPopGestureEnabled<T>(PageRoute<T> route) { 87 static bool _isPopGestureEnabled<T>(PageRoute<T> route) {
88 - if (route.isFirst) return false;  
89 -  
90 - if (route.willHandlePopInternally) return false;  
91 -  
92 - if (route.hasScopedWillPopCallback) return false;  
93 -  
94 - if (route.fullscreenDialog) return false;  
95 -  
96 - if (route.animation.status != AnimationStatus.completed) return false;  
97 -  
98 - if (route.secondaryAnimation.status != AnimationStatus.dismissed) {  
99 - return false;  
100 - }  
101 -  
102 - if (isPopGestureInProgress(route)) return false; 88 + // ignore: lines_longer_than_80_chars
  89 + if (route.isFirst ||
  90 + route.willHandlePopInternally ||
  91 + route.hasScopedWillPopCallback ||
  92 + route.fullscreenDialog ||
  93 + route.animation.status != AnimationStatus.completed ||
  94 + route.secondaryAnimation.status != AnimationStatus.dismissed ||
  95 + isPopGestureInProgress(route)) return false;
103 96
104 return true; 97 return true;
105 } 98 }
@@ -120,9 +113,7 @@ class GetPageRoute<T> extends PageRoute<T> { @@ -120,9 +113,7 @@ class GetPageRoute<T> extends PageRoute<T> {
120 Animation<double> animation, 113 Animation<double> animation,
121 Animation<double> secondaryAnimation, 114 Animation<double> secondaryAnimation,
122 ) { 115 ) {
123 - if (binding != null) {  
124 - binding.dependencies();  
125 - } 116 + binding?.dependencies();
126 if (bindings != null) { 117 if (bindings != null) {
127 for (final binding in bindings) { 118 for (final binding in bindings) {
128 binding.dependencies(); 119 binding.dependencies();
@@ -55,7 +55,7 @@ class GetObserver extends NavigatorObserver { @@ -55,7 +55,7 @@ class GetObserver extends NavigatorObserver {
55 55
56 String name(Route<dynamic> route) { 56 String name(Route<dynamic> route) {
57 if (route?.settings?.name != null) { 57 if (route?.settings?.name != null) {
58 - return route?.settings?.name; 58 + return route.settings.name;
59 } else if (route is GetPageRoute) { 59 } else if (route is GetPageRoute) {
60 return route.routeName; 60 return route.routeName;
61 } else if (route is GetDialogRoute) { 61 } else if (route is GetDialogRoute) {
@@ -77,9 +77,7 @@ class GetObserver extends NavigatorObserver { @@ -77,9 +77,7 @@ class GetObserver extends NavigatorObserver {
77 77
78 if (isSnackbar) { 78 if (isSnackbar) {
79 GetConfig.log("OPEN SNACKBAR $routeName"); 79 GetConfig.log("OPEN SNACKBAR $routeName");
80 - } else if (isBottomSheet) {  
81 - GetConfig.log("OPEN $routeName");  
82 - } else if (isDialog) { 80 + } else if (isBottomSheet || isDialog) {
83 GetConfig.log("OPEN $routeName"); 81 GetConfig.log("OPEN $routeName");
84 } else if (isGetPageRoute) { 82 } else if (isGetPageRoute) {
85 GetConfig.log("GOING TO ROUTE $routeName"); 83 GetConfig.log("GOING TO ROUTE $routeName");
@@ -112,9 +110,7 @@ class GetObserver extends NavigatorObserver { @@ -112,9 +110,7 @@ class GetObserver extends NavigatorObserver {
112 110
113 if (isSnackbar) { 111 if (isSnackbar) {
114 GetConfig.log("CLOSE SNACKBAR $routeName"); 112 GetConfig.log("CLOSE SNACKBAR $routeName");
115 - } else if (isBottomSheet) {  
116 - GetConfig.log("CLOSE $routeName");  
117 - } else if (isDialog) { 113 + } else if (isBottomSheet || isDialog) {
118 GetConfig.log("CLOSE $routeName"); 114 GetConfig.log("CLOSE $routeName");
119 } else if (isGetPageRoute) { 115 } else if (isGetPageRoute) {
120 GetConfig.log("CLOSE TO ROUTE $routeName"); 116 GetConfig.log("CLOSE TO ROUTE $routeName");
@@ -686,14 +686,11 @@ class _GetBarState<K extends Object> extends State<GetBar> @@ -686,14 +686,11 @@ class _GetBarState<K extends Object> extends State<GetBar>
686 } 686 }
687 687
688 Widget _getTitleText() { 688 Widget _getTitleText() {
689 - return widget.titleText != null  
690 - ? widget.titleText  
691 - : Text( 689 + return widget.titleText ??
  690 + Text(
692 widget.title ?? "", 691 widget.title ?? "",
693 style: TextStyle( 692 style: TextStyle(
694 - fontSize: 16.0,  
695 - color: Colors.white,  
696 - fontWeight: FontWeight.bold), 693 + fontSize: 16.0, color: Colors.white, fontWeight: FontWeight.bold),
697 ); 694 );
698 } 695 }
699 696
@@ -705,11 +702,7 @@ class _GetBarState<K extends Object> extends State<GetBar> @@ -705,11 +702,7 @@ class _GetBarState<K extends Object> extends State<GetBar>
705 } 702 }
706 703
707 FlatButton _getMainActionButton() { 704 FlatButton _getMainActionButton() {
708 - if (widget.mainButton != null) {  
709 return widget.mainButton; 705 return widget.mainButton;
710 - } else {  
711 - return null;  
712 - }  
713 } 706 }
714 } 707 }
715 708
@@ -154,9 +154,8 @@ class SnackRoute<T> extends OverlayRoute<T> { @@ -154,9 +154,8 @@ class SnackRoute<T> extends OverlayRoute<T> {
154 } else { 154 } else {
155 if (snack.snackPosition == SnackPosition.TOP) { 155 if (snack.snackPosition == SnackPosition.TOP) {
156 return DismissDirection.up; 156 return DismissDirection.up;
157 - } else {  
158 - return DismissDirection.down;  
159 } 157 }
  158 + return DismissDirection.down;
160 } 159 }
161 } 160 }
162 161
@@ -3,7 +3,6 @@ import 'dart:collection'; @@ -3,7 +3,6 @@ import 'dart:collection';
3 3
4 import '../rx_core/rx_interface.dart'; 4 import '../rx_core/rx_interface.dart';
5 5
6 -  
7 /// global object that registers against `GetX` and `Obx`, and allows the 6 /// global object that registers against `GetX` and `Obx`, and allows the
8 /// reactivity 7 /// reactivity
9 /// of those `Widgets` and Rx values. 8 /// of those `Widgets` and Rx values.
@@ -115,7 +114,7 @@ class _RxImpl<T> implements RxInterface<T> { @@ -115,7 +114,7 @@ class _RxImpl<T> implements RxInterface<T> {
115 /// print('${inputError.runtimeType}: $inputError'); // outputs > RxString: null 114 /// print('${inputError.runtimeType}: $inputError'); // outputs > RxString: null
116 /// ``` 115 /// ```
117 void nil() { 116 void nil() {
118 - subject.add(_value=null); 117 + subject.add(_value = null);
119 } 118 }
120 119
121 /// Same as `toString()` but using a getter. 120 /// Same as `toString()` but using a getter.
@@ -162,7 +161,6 @@ class _RxImpl<T> implements RxInterface<T> { @@ -162,7 +161,6 @@ class _RxImpl<T> implements RxInterface<T> {
162 161
163 bool firstRebuild = true; 162 bool firstRebuild = true;
164 163
165 -  
166 /// Updates the [value] and adds it to the stream, updating the observer 164 /// Updates the [value] and adds it to the stream, updating the observer
167 /// Widget, only if it's different from the previous value. 165 /// Widget, only if it's different from the previous value.
168 set value(T val) { 166 set value(T val) {
@@ -186,14 +184,12 @@ class _RxImpl<T> implements RxInterface<T> { @@ -186,14 +184,12 @@ class _RxImpl<T> implements RxInterface<T> {
186 {Function onError, void Function() onDone, bool cancelOnError}) => 184 {Function onError, void Function() onDone, bool cancelOnError}) =>
187 stream.listen(onData, onError: onError, onDone: onDone); 185 stream.listen(onData, onError: onError, onDone: onDone);
188 186
189 -  
190 /// Binds an existing stream to this Rx to keep the values in sync. 187 /// Binds an existing stream to this Rx to keep the values in sync.
191 void bindStream(Stream<T> stream) => stream.listen((va) => value = va); 188 void bindStream(Stream<T> stream) => stream.listen((va) => value = va);
192 189
193 Stream<R> map<R>(R mapper(T data)) => stream.map(mapper); 190 Stream<R> map<R>(R mapper(T data)) => stream.map(mapper);
194 } 191 }
195 192
196 -  
197 /// Rx class for `bool` Type. 193 /// Rx class for `bool` Type.
198 class RxBool extends _RxImpl<bool> { 194 class RxBool extends _RxImpl<bool> {
199 RxBool([bool initial]) { 195 RxBool([bool initial]) {
@@ -298,7 +294,6 @@ class RxInt extends _BaseRxNum<int> { @@ -298,7 +294,6 @@ class RxInt extends _BaseRxNum<int> {
298 } 294 }
299 } 295 }
300 296
301 -  
302 /// Foundation class used for custom `Types` outside the common native Dart 297 /// Foundation class used for custom `Types` outside the common native Dart
303 /// types. 298 /// types.
304 /// For example, any custom "Model" class, like User().obs will use `Rx` as 299 /// For example, any custom "Model" class, like User().obs will use `Rx` as