Jonny Borges
Committed by GitHub

update to 3.1.0

Added extensions to GetUtils and fix typo on GetUtils.isEmail (@stefandevo)
Added .gitignore file (@hdeyana)
Fix initialRoute on web
## [3.1.0]
- Added extensions to GetUtils and fix typo on GetUtils.isEmail (@stefandevo)
- Added .gitignore file (@hdeyana)
## [3.0.1]
- Breaking changes on Rx api and GetController and RxController were merged, and now you only have the 'GetxController'
- Refactor routing system. Now you can add custom transitions and more
... ... @@ -13,7 +17,8 @@
## [2.14.0]
- Added getPages API.
- Deprecated namedPages
- Fix default transition
- Fix default transition
- Added Duration on Get.offAll(@kluverua)
## [2.13.1]
- Added sort to ListX
... ... @@ -57,7 +62,7 @@
- Added Permissions:
You can now revoke permissions to SmartManagement so that it cannot delete a particular controller.
Add to Get.put (Controller(), permanent: true); to make it indelible.
Get.lazyPut () will not receive this resource. Initially he had it, but we saw in internal tests that it could cause problems with the bindings API. Bindings were created to initialize and delete an instance, if it were allowed to make a controller started with lazyPut permanent, copies of that Controller would be created every time Binding was called. For the safety of users, especially new users who could easily do this, it was decided that this feature will only be present in Get.put.
Get.lazyPut() will not receive this resource. Initially he had it, but we saw in internal tests that it could cause problems with the bindings API. Bindings were created to initialize and delete an instance, if it were allowed to make a controller started with lazyPut permanent, copies of that Controller would be created every time Binding was called. For the safety of users, especially new users who could easily do this, it was decided that this feature will only be present in Get.put.
- Improve: Now a controller's life cycle has no connection with the View life cycle. It is no longer called internally in an "initState", it is now called when the Controller enters memory. This means that now onInit will always be called, regardless of where you started your dependency.
- removed: this property of the update() method has been permanently removed.
... ... @@ -76,20 +81,23 @@ Get.lazyPut () will not receive this resource. Initially he had it, but we saw i
## [2.10.0]
- Added SmartManagement, your application's memory is managed intelligently like never before!
- Added Obx, a widget that knows when to rebuild a child, without needing any type.
- Added MIxinBuilder - If you need to use GetBuilder in conjunction with GetX, use GetxController with this widget, and the changes will occur either using update (this) or changing some reactive variable. Use only if necessary, for better RAM consumption, prefer widgets in that order:
- Added MixinBuilder - If you need to use GetBuilder in conjunction with GetX, use GetxController with this widget, and the changes will occur either using update (this) or changing some reactive variable. Use only if necessary, for better RAM consumption, prefer widgets in that order:
Obx => GetX => GetBuilder => MixinBuilder.
Obx is the lightest of all, and MixinBuilder is a mix of the other 3, whenever possible, use the specific widget.
- Refactor: refactor StateManager of Get.
- Refactor: StateManager of Get.
- Changed: full List API refactor, now value is no longer needed.
- Added Workers: You can hear changes to a variable and trigger custom callbacks.
- Added Bindings API docs.
- Added Portuguese language to readme(@Nipodemos)
# [2.7.1]
- Improve list to set and get methods
## [2.7.0]
- Added obx, a simple state interceptor.
- Improve Bindings, ListX, and fix docs typos
- Improve Bindings, ListX, and
- fix docs typos e broken code (@ghprod)
## [2.6.3]
- Flutter currently has a problem on some devices where using showModalBottomSheet() can cause TextFields to be hidden behind the keyboard (https://github.com/flutter/flutter/issues/18564) this issue is closed, even users reporting that the problem still occurs.
... ... @@ -116,6 +124,7 @@ This feature had been deprecated in previous updates, and was removed in version
## [2.5.8]
- Added docs
- Added tests(@chimon2000)
## [2.5.7]
- Fix Get.generalDialog optionals
... ... @@ -124,6 +133,7 @@ This feature had been deprecated in previous updates, and was removed in version
## [2.5.6]
- GetBuilder refactor to work with lazyPut.
Now you can list your controllers in advance with Get.lazyPut, and only when it is called for the first time will it be relocated in memory.
- Fix english typos(@gumbarros)
## [2.5.5]
- Fix arguments broken by new methods
... ... @@ -134,6 +144,7 @@ Now you can list your controllers in advance with Get.lazyPut, and only when it
## [2.5.3]
- Fix snackbar padding on iPhone SE 2.
- Added themes docs
- Added ThemeMode (@RodBr)
## [2.5.2]
- Fix: key not found when Get.key is used with no MaterialApp
... ... @@ -182,7 +193,7 @@ Now you can list your controllers in advance with Get.lazyPut, and only when it
- Fix GetRoute not found
## [2.2.1]
- Improve lazyPut
- Improve lazyPut and fix tag to lazyput(@rochadaniel)
## [2.2.0]
- Added: Ability to choose or delay a widget's state change according to its ID.
... ... @@ -326,6 +337,7 @@ Now you can list your controllers in advance with Get.lazyPut, and only when it
## [1.10.2]
-Improve snackbar text color
-Added background color to snackbar (@claudneysessa)
## [1.10.1]
-Backdrop improvement
... ...
... ... @@ -14,11 +14,12 @@
<!-- ALL-CONTRIBUTORS-BADGE:END -->
- Get is an extra-light and powerful solution for Flutter. It combines high performance state management, intelligent dependency injection, and route management in a quick and practical way.
- Get is not for everyone, its focus is (performance) on the minimum consumption of resources ([look the benchmarks](https://github.com/jonataslaw/benchmarks)), (productivity) using an easy and pleasant syntax and (organization) allowing the total decoupling of the View from the business logic.
- Get will save hours of development, and will extract the maximum performance that your application can deliver, being easy for beginners, and accurate for experts. Navigate without context, open dialogs, snackbars or bottomsheets from anywhere in your code, Manage states and inject dependencies in an easy and practical way. Get is secure, stable, up-to-date, and offers a huge range of APIs that are not present on default framework.
- GetX is an extra-light and powerful solution for Flutter. It combines high performance state management, intelligent dependency injection, and route management in a quick and practical way.
- GetX is not for everyone, its focus is (performance) on the minimum consumption of resources ([look the benchmarks](https://github.com/jonataslaw/benchmarks)), (productivity) using an easy and pleasant syntax and (organization) allowing the total decoupling of the View from the business logic.
- GetX will save hours of development, and will extract the maximum performance that your application can deliver, being easy for beginners, and accurate for experts. Navigate without context, open dialogs, snackbars or bottomsheets from anywhere in your code, Manage states and inject dependencies in an easy and practical way. Get is secure, stable, up-to-date, and offers a huge range of APIs that are not present on default framework.
- GetX is not a blot. It has a multitude of features that allow you to start programming without worrying about anything, but each of these features are in separate containers, and are only started after use. If you only use State Management, only State Management will be compiled. If you only use routes, nothing from the state management will be compiled. You can compile the benchmark repository, and you will see that using only Get state management, the application compiled with Get has become smaller than all other applications that have only the state management of other packages, because nothing that is not used will be compiled into your code, and each GetX solution was designed to be extra lightweight. The merit here also comes from Flutter's AOT which is incredible, and manages to eliminate unused resources like no other framework does.
**Get makes your development productive, but want to make it even more productive? Add the extension [Get extension to VSCode](https://marketplace.visualstudio.com/items?itemName=get-snippets.get-snippets) to your VSCode**
**GetX makes your development productive, but want to make it even more productive? Add the extension [GetX extension to VSCode](https://marketplace.visualstudio.com/items?itemName=get-snippets.get-snippets) to your VSCode**
The "counter" project created by default on new project on Flutter has over 100 lines (with comments). To show the power of Get, I will demonstrate how to make a "counter" changing the state with each click, switching between pages and sharing the state between screens, all in an organized way, separating the business logic from the view, in ONLY 26 LINES CODE INCLUDING COMMENTS.
... ... @@ -28,6 +29,8 @@ Add "Get" before your materialApp, turning it into GetMaterialApp
```dart
void main() => runApp(GetMaterialApp(home: Home()));
```
- Note: this does not modify the MaterialApp of the Flutter, GetMaterialApp is not a modified MaterialApp, it is just a pre-configured Widget, which has the default MaterialApp as a child. You can configure this manually, but it is definitely not necessary. GetMaterialApp will create routes, inject them, inject translations, inject everything you need for route navigation. If you use Get only for state management or dependency management, it is not necessary to use GetMaterialApp. GetMaterialApp is necessary for routes, snackbars, internationalization, bottomSheets, dialogs, and high-level apis related to routes and absence of context.
- Step 2:
Create your business logic class and place all variables, methods and controllers inside it.
You can make any variable observable using a simple ".obs".
... ...
... ... @@ -8,7 +8,6 @@ export 'src/snackbar/snack_route.dart';
export 'src/state/get_state.dart';
export 'src/state/get_view.dart';
export 'src/regex/get_utils.dart';
export 'src/regex/get_utils_extensions.dart';
export 'src/queue/get_queue.dart';
export 'src/state/mixin_state.dart';
export 'src/rx/rx_interface.dart';
... ... @@ -24,5 +23,6 @@ export 'src/routes/bindings_interface.dart';
export 'src/routes/observers/route_observer.dart';
export 'src/routes/transitions_type.dart';
export 'src/platform/platform.dart';
export 'src/extension_instance.dart';
export 'src/instance/extension_instance.dart';
export 'src/routes/custom_transition.dart';
export 'src/context_extensions/extensions.dart';
... ...
import 'package:flutter/widgets.dart';
extension MDQ on BuildContext {
Size get mediaQuerySize => MediaQuery.of(this).size;
double get height => mediaQuerySize.height;
double get width => mediaQuerySize.width;
double heightTransformer({double dividedBy = 1, double reducedBy = 0.0}) {
return (mediaQuerySize.height -
((mediaQuerySize.height / 100) * reducedBy)) /
dividedBy;
}
double widthTransformer({double dividedBy = 1, double reducedBy = 0.0}) {
return (mediaQuerySize.width - ((mediaQuerySize.width / 100) * reducedBy)) /
dividedBy;
}
double ratio(
{double dividedBy = 1,
double reducedByW = 0.0,
double reducedByH = 0.0}) {
return heightTransformer(dividedBy: dividedBy, reducedBy: reducedByH) /
widthTransformer(dividedBy: dividedBy, reducedBy: reducedByW);
}
/// similar to MediaQuery.of(this).padding
EdgeInsets get mediaQueryPadding => MediaQuery.of(this).padding;
/// similar to MediaQuery.of(this).viewPadding
EdgeInsets get mediaQueryViewPadding => MediaQuery.of(this).viewPadding;
/// similar to MediaQuery.of(this).viewInsets;
EdgeInsets get mediaQueryViewInsets => MediaQuery.of(this).viewInsets;
/// similar to MediaQuery.of(this).orientation;
Orientation get orientation => MediaQuery.of(this).orientation;
/// check if device is on landscape mode
bool get isLandscape => orientation == Orientation.landscape;
/// check if device is on portrait mode
bool get isPortrait => orientation == Orientation.portrait;
/// similar to MediaQuery.of(this).devicePixelRatio;
double get devicePixelRatio => MediaQuery.of(this).devicePixelRatio;
/// similar to MediaQuery.of(this).textScaleFactor;
double get textScaleFactor => MediaQuery.of(this).textScaleFactor;
/// get the shortestSide from screen
double get mediaQueryShortestSide => mediaQuerySize.shortestSide;
/// True if width be larger than 800
bool get showNavbar => (width > 800);
/// True if the shortestSide is smaller than 600p
bool get isPhone => (mediaQueryShortestSide < 600);
/// True if the shortestSide is largest than 600p
bool get isSmallTablet => (mediaQueryShortestSide >= 600);
/// True if the shortestSide is largest than 720p
bool get isLargeTablet => (mediaQueryShortestSide >= 720);
/// True if the current device is Tablet
bool get isTablet => isSmallTablet || isLargeTablet;
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:get/get.dart';
import 'package:get/src/get_instance.dart';
import 'package:get/src/instance/get_instance.dart';
import 'package:get/src/get_interface.dart';
import 'bottomsheet/bottomsheet.dart';
import 'instance/get_instance.dart';
import 'platform/platform.dart';
import 'root/parse_route.dart';
import 'root/root_controller.dart';
... ... @@ -22,8 +23,7 @@ import 'snackbar/snack.dart';
class GetImpl implements GetService {
bool defaultPopGesture = GetPlatform.isIOS;
bool defaultOpaqueRoute = true;
Transition defaultTransition =
(GetPlatform.isIOS ? Transition.leftToRight : Transition.fadeIn);
Transition defaultTransition;
Duration defaultDurationTransition = Duration(milliseconds: 400);
bool defaultGlobalState = true;
RouteSettings settings;
... ... @@ -631,16 +631,27 @@ class GetImpl implements GetService {
}
}
CustomTransition customTransition;
GetMaterialController getxController = GetMaterialController();
Locale locale;
void updateLocale(Locale l) {
locale = l;
getxController.update();
forceAppUpdate();
}
void forceAppUpdate() {
void rebuild(Element el) {
el.markNeedsBuild();
el.visitChildren(rebuild);
}
(context as Element).visitChildren(rebuild);
}
Map<String, Map<String, String>> translations;
Map<String, Map<String, String>> translations = {};
void addTranslations(Map<String, Map<String, String>> tr) {
translations.addAll(tr);
... ...
import 'package:get/src/typedefs/typedefs.dart';
import '../get_main.dart';
import 'get_instance.dart';
extension Inst on GetImpl {
void lazyPut<S>(FcBuilderFunc builder, {String tag}) {
return GetInstance().lazyPut<S>(builder, tag: tag);
}
Future<S> putAsync<S>(FcBuilderFuncAsync<S> builder,
{String tag, bool permanent = false}) async =>
GetInstance().putAsync<S>(builder, tag: tag, permanent: permanent);
S find<S>({String tag, FcBuilderFunc<S> instance}) =>
GetInstance().find<S>(tag: tag, instance: instance);
S put<S>(S dependency,
{String tag,
bool permanent = false,
bool overrideAbstract = false,
FcBuilderFunc<S> builder}) =>
GetInstance().put<S>(dependency,
tag: tag,
permanent: permanent,
overrideAbstract: overrideAbstract,
builder: builder);
bool reset({bool clearFactory = true, bool clearRouteBindings = true}) =>
GetInstance().reset(
clearFactory: clearFactory, clearRouteBindings: clearRouteBindings);
/// Delete class instance on [S] and clean memory
Future<bool> delete<S>({String tag, String key}) async =>
GetInstance().delete<S>(tag: tag, key: key);
bool isRegistred<S>({String tag}) => GetInstance().isRegistred<S>(tag: tag);
}
... ...
import 'package:get/src/root/smart_management.dart';
import 'package:get/src/rx/rx_interface.dart';
import 'package:get/src/typedefs/typedefs.dart';
class GetConfig {
//////////// INSTANCE MANAGER
static Map<dynamic, dynamic> _singl = {};
static Map<dynamic, FcBuilderFunc> _factory = {};
static Map<String, String> routesKey = {};
static SmartManagement smartManagement = SmartManagement.full;
static bool isLogEnable = true;
static String currentRoute;
}
class GetInstance {
factory GetInstance() {
if (_getInstance == null) _getInstance = GetInstance._();
return _getInstance;
}
GetInstance._();
static GetInstance _getInstance;
void lazyPut<S>(FcBuilderFunc builder, {String tag}) {
String key = _getKey(S, tag);
GetConfig._factory.putIfAbsent(key, () => builder);
}
Future<S> putAsync<S>(FcBuilderFuncAsync<S> builder,
{String tag, bool permanent = false}) async {
return put<S>(await builder(), tag: tag, permanent: permanent);
}
/// Inject class on Get Instance Manager
S put<S>(
S dependency, {
String tag,
bool permanent = false,
bool overrideAbstract = false,
FcBuilderFunc<S> builder,
}) {
_insert(
isSingleton: true,
replace: overrideAbstract,
//?? (("$S" == "${dependency.runtimeType}") == false),
name: tag,
permanent: permanent,
builder: builder ?? (() => dependency));
return find<S>(tag: tag);
}
/// Create a new instance from builder class
/// Example
/// create(() => Repl());
/// Repl a = find();
/// Repl b = find();
/// print(a==b); (false)
void create<S>(
FcBuilderFunc<S> builder, {
String name,
}) {
_insert(isSingleton: false, name: name, builder: builder);
}
void _insert<S>({
bool isSingleton,
String name,
bool replace = true,
bool permanent = false,
FcBuilderFunc<S> builder,
}) {
assert(builder != null);
String key = _getKey(S, name);
if (replace) {
GetConfig._singl[key] = FcBuilder<S>(isSingleton, builder, permanent);
} else {
GetConfig._singl.putIfAbsent(
key, () => FcBuilder<S>(isSingleton, builder, permanent));
}
}
void removeDependencyByRoute(String routeName) async {
List<String> keysToRemove = [];
GetConfig.routesKey.forEach((key, value) {
// if (value == routeName && value != null) {
if (value == routeName) {
keysToRemove.add(key);
}
});
keysToRemove.forEach((element) async {
await delete(key: element);
});
keysToRemove.forEach((element) {
GetConfig.routesKey?.remove(element);
});
keysToRemove.clear();
}
bool isRouteDependecyNull<S>({String name}) {
return (GetConfig.routesKey[_getKey(S, name)] == null);
}
bool isDependencyInit<S>({String name}) {
String key = _getKey(S, name);
return GetConfig.routesKey.containsKey(key);
}
void registerRouteInstance<S>({String tag}) {
GetConfig.routesKey
.putIfAbsent(_getKey(S, tag), () => GetConfig.currentRoute);
}
S findByType<S>(Type type, {String tag}) {
String key = _getKey(type, tag);
return GetConfig._singl[key].getSependency() as S;
}
void initController<S>({String tag}) {
String key = _getKey(S, tag);
final i = GetConfig._singl[key].getSependency();
if (i is DisposableInterface) {
i.onStart();
if (GetConfig.isLogEnable) print('[GET] $key has been initialized');
}
}
/// Find a instance from required class
S find<S>({String tag, FcBuilderFunc<S> instance}) {
String key = _getKey(S, tag);
bool callInit = false;
if (isRegistred<S>(tag: tag)) {
if (!isDependencyInit<S>() &&
GetConfig.smartManagement != SmartManagement.onlyBuilder) {
registerRouteInstance<S>(tag: tag);
callInit = true;
}
FcBuilder builder = GetConfig._singl[key] as FcBuilder;
if (builder == null) {
if (tag == null) {
throw "class ${S.toString()} is not register";
} else {
throw "class ${S.toString()} with tag '$tag' is not register";
}
}
if (callInit) {
initController<S>(tag: tag);
}
return GetConfig._singl[key].getSependency() as S;
} else {
if (!GetConfig._factory.containsKey(key))
throw " $S not found. You need call put<$S>($S()) before";
if (GetConfig.isLogEnable)
print('[GET] $S instance was created at that time');
S _value = put<S>(GetConfig._factory[key].call() as S);
if (!isDependencyInit<S>() &&
GetConfig.smartManagement != SmartManagement.onlyBuilder) {
registerRouteInstance<S>(tag: tag);
callInit = true;
}
if (GetConfig.smartManagement != SmartManagement.keepFactory) {
GetConfig._factory.remove(key);
}
if (callInit) {
initController<S>(tag: tag);
}
return _value;
}
}
/// Remove dependency of [S] on dependency abstraction. For concrete class use delete
void remove<S>({String tag}) {
String key = _getKey(S, tag);
FcBuilder builder = GetConfig._singl[key] as FcBuilder;
final i = builder.dependency;
if (i is DisposableInterface) {
i.onClose();
if (GetConfig.isLogEnable) print('[GET] onClose of $key called');
}
if (builder != null) builder.dependency = null;
if (GetConfig._singl.containsKey(key)) {
print('error on remove $key');
} else {
if (GetConfig.isLogEnable) print('[GET] $key removed from memory');
}
}
String _getKey(Type type, String name) {
return name == null ? type.toString() : type.toString() + name;
}
bool reset({bool clearFactory = true, bool clearRouteBindings = true}) {
if (clearFactory) GetConfig._factory.clear();
if (clearRouteBindings) GetConfig.routesKey.clear();
GetConfig._singl.clear();
return true;
}
/// Delete class instance on [S] and clean memory
Future<bool> delete<S>({String tag, String key}) async {
String newKey;
if (key == null) {
newKey = _getKey(S, tag);
} else {
newKey = key;
}
if (!GetConfig._singl.containsKey(newKey)) {
print('Instance $newKey not found');
return false;
}
FcBuilder builder = GetConfig._singl[newKey] as FcBuilder;
if (builder.permanent) {
(key == null)
? print(
'[GET] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.')
: print(
'[GET] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.');
return false;
}
final i = builder.dependency;
if (i is DisposableInterface) {
await i.onClose();
if (GetConfig.isLogEnable) print('[GET] onClose of $newKey called');
}
GetConfig._singl.removeWhere((oldkey, value) => (oldkey == newKey));
if (GetConfig._singl.containsKey(newKey)) {
print('[GET] error on remove object $newKey');
} else {
if (GetConfig.isLogEnable) print('[GET] $newKey deleted from memory');
}
// GetConfig.routesKey?.remove(key);
return true;
}
/// check if instance is registred
bool isRegistred<S>({String tag}) =>
GetConfig._singl.containsKey(_getKey(S, tag));
/// check if instance is prepared
bool isPrepared<S>({String tag}) =>
GetConfig._factory.containsKey(_getKey(S, tag));
}
... ...
... ... @@ -10,19 +10,19 @@ class GetPageMatch {
class ParseRouteTree {
final List<ParseRouteTreeNode> _nodes = <ParseRouteTreeNode>[];
// bool _hasDefaultRoute = false;
// bool _hasDefaultRoute = false;
void addRoute(GetPage route) {
String path = route.name;
if (path == Navigator.defaultRouteName) {
//if (_hasDefaultRoute) {
// throw ("Default route was already defined");
//}
// if (_hasDefaultRoute) {
// throw ("Default route was already defined");
// }
var node = ParseRouteTreeNode(path, ParseRouteTreeNodeType.component);
node.routes = [route];
_nodes.add(node);
// _hasDefaultRoute = true;
// _hasDefaultRoute = true;
return;
}
if (path.startsWith("/")) {
... ...
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/src/instance/get_instance.dart';
import 'package:get/src/routes/get_route.dart';
import '../get_instance.dart';
import 'parse_route.dart';
import 'root_controller.dart';
import 'smart_management.dart';
... ... @@ -24,6 +23,7 @@ class GetMaterialApp extends StatelessWidget {
this.title = '',
this.onGenerateTitle,
this.color,
this.customTransition,
this.onInit,
this.onDispose,
this.theme,
... ... @@ -77,6 +77,7 @@ class GetMaterialApp extends StatelessWidget {
final ThemeData theme;
final ThemeData darkTheme;
final ThemeMode themeMode;
final CustomTransition customTransition;
final Color color;
final Map<String, Map<String, String>> translationsKeys;
final Translations translations;
... ... @@ -126,6 +127,27 @@ class GetMaterialApp extends StatelessWidget {
);
}
List<Route<dynamic>> initialRoutesGenerate(String name) {
final match = Get.routeTree.matchRoute(name);
Get.parameters = match?.parameters;
return [
GetPageRoute(
page: match.route.page,
parameter: match.route.parameter,
settings: RouteSettings(name: name, arguments: null),
curve: match.route.curve,
opaque: match.route.opaque,
binding: match.route.binding,
bindings: match.route.bindings,
duration: (transitionDuration ?? match.route.transitionDuration),
transition: match.route.transition,
popGesture: match.route.popGesture,
fullscreenDialog: match.route.fullscreenDialog,
)
];
}
@override
Widget build(BuildContext context) {
return GetBuilder<GetMaterialController>(
... ... @@ -139,12 +161,13 @@ class GetMaterialApp extends StatelessWidget {
}
if (translations != null) {
if (Get.locale == null) Get.translations = translations.keys;
}
if (translationsKeys != null) {
Get.translations = translations.keys;
} else if (translationsKeys != null) {
Get.translations = translationsKeys;
}
Get.customTransition = customTransition;
initialBinding?.dependencies();
Get.addPages(getPages);
GetConfig.smartManagement = smartManagement;
... ... @@ -171,32 +194,7 @@ class GetMaterialApp extends StatelessWidget {
onGenerateRoute: (getPages != null ? generator : onGenerateRoute),
onGenerateInitialRoutes: (getPages == null || home != null)
? onGenerateInitialRoutes
: (st) {
GetPageMatch match;
if (initialRoute == null && getPages != null) {
match = Get.routeTree?.matchRoute(getPages.first.name);
} else {
match = Get.routeTree?.matchRoute(initialRoute);
}
Get.parameters = match?.parameters;
return [
GetPageRoute(
page: match.route.page,
parameter: match.parameters,
settings:
RouteSettings(name: initialRoute, arguments: null),
curve: match.route.curve,
opaque: match.route.opaque,
binding: match.route.binding,
bindings: match.route.bindings,
duration: (transitionDuration ??
match.route.transitionDuration),
transition: match.route.transition,
popGesture: match.route.popGesture,
fullscreenDialog: match.route.fullscreenDialog,
)
];
},
: initialRoutesGenerate,
onUnknownRoute: onUnknownRoute,
navigatorObservers: (navigatorObservers == null
? <NavigatorObserver>[GetObserver(routingCallback)]
... ... @@ -235,14 +233,18 @@ abstract class Translations {
extension Trans on String {
String get tr {
if (Get.locale?.languageCode == null) return this;
if (Get.translations
.containsKey("${Get.locale.languageCode}_${Get.locale.countryCode}")) {
return Get.translations[
"${Get.locale.languageCode}_${Get.locale.countryCode}"][this];
} else if (Get.translations.containsKey(Get.locale.languageCode)) {
return Get.translations[Get.locale.languageCode][this];
} else if (Get.translations.isNotEmpty) {
return Get.translations.values.first[this];
} else {
return this;
}
return Get.translations.values.first[this];
}
String trArgs([List<String> args]) {
... ...
... ... @@ -2,8 +2,8 @@ import 'dart:math';
import 'dart:ui' show lerpDouble;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:get/src/get_instance.dart';
import 'package:get/src/get_main.dart';
import 'package:get/src/instance/get_instance.dart';
import 'package:get/src/platform/platform.dart';
import 'bindings_interface.dart';
import 'custom_transition.dart';
... ... @@ -73,8 +73,39 @@ class GetPageRoute<T> extends PageRouteBuilder<T> {
child: child)
: child);
}
final curvedAnimation = CurvedAnimation(
parent: animation,
curve: this.curve ?? Curves.linear,
);
if (transition == null) {
if (Get.customTransition != null) {
return Get.customTransition.buildTransition(
context,
animation,
secondaryAnimation,
popGesture ?? Get.defaultPopGesture
? _CupertinoBackGestureDetector<T>(
enabledCallback: () => _isPopGestureEnabled<T>(this),
onStartPopGesture: () => _startPopGesture<T>(this),
child: child)
: child);
}
if (Get.defaultTransition != null) {
return TransitionFilter.newTransitionComponent(Get.defaultTransition)
.buildChildWithTransition(
context,
curvedAnimation,
secondaryAnimation,
popGesture ?? Get.defaultPopGesture
? _CupertinoBackGestureDetector<T>(
enabledCallback: () => _isPopGestureEnabled<T>(this),
onStartPopGesture: () => _startPopGesture<T>(this),
child: child)
: child);
}
if (transition == Transition.native) {
return Theme.of(context).pageTransitionsTheme.buildTransitions(
this,
context,
... ... @@ -88,11 +119,6 @@ class GetPageRoute<T> extends PageRouteBuilder<T> {
: child);
}
final curvedAnimation = CurvedAnimation(
parent: animation,
curve: this.curve ?? Curves.linear,
);
return TransitionFilter.newTransitionComponent(transition)
.buildChildWithTransition(
context,
... ...
... ... @@ -2,7 +2,6 @@ import 'package:flutter/widgets.dart';
import 'package:get/src/routes/bindings_interface.dart';
import 'transitions_type.dart';
class GetPage {
final String name;
final GetPageBuilder page;
... ... @@ -43,4 +42,3 @@ class GetPage {
assert(maintainState != null),
assert(fullscreenDialog != null);
}
... ...
import 'package:flutter/widgets.dart';
import 'package:get/src/instance/get_instance.dart';
import 'package:get/src/root/smart_management.dart';
import '../../get_instance.dart';
import '../../get_main.dart';
class Routing {
... ...
import 'package:flutter/widgets.dart';
import 'package:get/src/instance/get_instance.dart';
import 'package:get/src/root/smart_management.dart';
import '../get_instance.dart';
import 'rx_impl.dart';
import 'rx_interface.dart';
... ...
import 'package:flutter/widgets.dart';
import 'package:get/src/get_instance.dart';
import 'package:get/src/instance/get_instance.dart';
import 'package:get/src/root/smart_management.dart';
import 'package:get/src/rx/rx_interface.dart';
... ...
import 'package:flutter/widgets.dart';
import 'package:get/src/get_instance.dart';
import 'package:get/src/instance/get_instance.dart';
abstract class GetView<T> extends StatelessWidget {
const GetView({Key key}) : super(key: key);
... ...
... ... @@ -134,7 +134,7 @@ packages:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.2.0"
vector_math:
dependency: transitive
description:
... ...
name: get
description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
version: 3.0.1
version: 3.1.0
homepage: https://github.com/jonataslaw/get
environment:
... ...
... ... @@ -18,14 +18,13 @@ void main() {
});
testWidgets("Get.toNamed smoke test", (tester) async {
await tester.pumpWidget(
Wrapper(
GetMaterialApp(
initialRoute: '/',
namedRoutes: [
getPages: [
GetPage(page: () => FirstScreen(), name: '/'),
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third'),
],
child: Container(),
),
);
... ... @@ -56,15 +55,14 @@ void main() {
testWidgets("Get.offNamed smoke test", (tester) async {
await tester.pumpWidget(
Wrapper(
GetMaterialApp(
initialRoute: '/',
namedRoutes: [
getPages: [
GetPage(name: '/', page: () => Container()),
GetPage(name: '/first', page: () => FirstScreen()),
GetPage(name: '/second', page: () => SecondScreen()),
GetPage(name: '/third', page: () => ThirdScreen()),
],
child: Container(),
),
);
... ... @@ -107,7 +105,7 @@ void main() {
testWidgets("Get.offAllNamed smoke test", (tester) async {
await tester.pumpWidget(
Wrapper(
WrapperNamed(
initialRoute: '/',
namedRoutes: [
GetPage(page: () => Container(), name: '/'),
... ... @@ -115,7 +113,6 @@ void main() {
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third'),
],
child: Container(),
),
);
... ... @@ -140,7 +137,7 @@ void main() {
testWidgets("Get.offAndToNamed smoke test", (tester) async {
await tester.pumpWidget(
Wrapper(
WrapperNamed(
initialRoute: '/',
namedRoutes: [
GetPage(page: () => Container(), name: '/'),
... ... @@ -148,7 +145,6 @@ void main() {
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third'),
],
child: Container(),
),
);
... ... @@ -189,7 +185,7 @@ void main() {
testWidgets("Get.offNamedUntil smoke test", (tester) async {
await tester.pumpWidget(
Wrapper(
WrapperNamed(
initialRoute: '/',
namedRoutes: [
GetPage(page: () => Container(), name: '/'),
... ... @@ -197,7 +193,6 @@ void main() {
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third'),
],
child: Container(),
),
);
... ...
... ... @@ -27,3 +27,27 @@ class Wrapper extends StatelessWidget {
);
}
}
class WrapperNamed extends StatelessWidget {
final Widget child;
final List<GetPage> namedRoutes;
final String initialRoute;
final Transition defaultTransition;
const WrapperNamed({
Key key,
this.child,
this.namedRoutes,
this.initialRoute,
this.defaultTransition,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GetMaterialApp(
defaultTransition: defaultTransition,
initialRoute: initialRoute,
getPages: namedRoutes,
);
}
}
... ...