Skip to content

Commit

Permalink
Update to 3.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jonataslaw authored Aug 7, 2020
1 parent ed6904a commit 214268a
Show file tree
Hide file tree
Showing 14 changed files with 300 additions and 75 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [3.4.3]
- Fix onInit fired only first time
- Fix language callback(@lundin)
- Fix docs (@nipodemos)

## [3.4.2]
- Fix individual imports

## [3.4.1]
- Structure organization, and improvements.

Expand Down
8 changes: 4 additions & 4 deletions lib/get.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library get;

export 'src/instance/instance_manager.dart';
export 'src/navigation/route_manager.dart';
export 'src/state_manager/state_manager.dart';
export 'src/utils/utils.dart';
export 'instance_manager.dart';
export 'route_manager.dart';
export 'state_manager.dart';
export 'utils.dart';
3 changes: 3 additions & 0 deletions lib/instance_manager.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export 'src/instance/get_instance.dart';
export 'src/instance/extension_instance.dart';
export 'src/navigation/routes/bindings_interface.dart';
13 changes: 13 additions & 0 deletions lib/route_manager.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export 'src/navigation/routes/custom_transition.dart';
export 'src/navigation/routes/transitions_type.dart';
export 'src/navigation/routes/get_route.dart';
export 'src/navigation/routes/default_route.dart';
export 'src/navigation/routes/observers/route_observer.dart';
export 'src/navigation/root/root_widget.dart';
export 'src/navigation/snackbar/snack_route.dart';
export 'src/navigation/bottomsheet/bottomsheet.dart';
export 'src/navigation/snackbar/snack.dart';
export 'src/get_main.dart';
export 'src/navigation/routes/default_route.dart';
export 'src/navigation/root/smart_management.dart';
export 'src/navigation/extension_navigation.dart';
4 changes: 2 additions & 2 deletions lib/src/get_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'navigation/root/root_controller.dart';
import 'navigation/routes/custom_transition.dart';
import 'navigation/routes/observers/route_observer.dart';
import 'navigation/routes/transitions_type.dart';
import 'utils/utils.dart';
import '../utils.dart';

///Use Get.to instead of Navigator.push, Get.off instead of Navigator.pushReplacement,
///Get.offAll instead of Navigator.pushAndRemoveUntil. For named routes just add "named"
Expand Down Expand Up @@ -33,7 +33,7 @@ abstract class GetInterface {
GetMaterialController getxController = GetMaterialController();

Locale locale;

Locale fallbackLocale;

GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>();
Expand Down
49 changes: 21 additions & 28 deletions lib/src/instance/get_instance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class GetInstance {
assert(builder != null);
String key = _getKey(S, name);

GetConfig._singl
.putIfAbsent(key, () => FcBuilder<S>(isSingleton, builder, permanent));
GetConfig._singl.putIfAbsent(
key, () => FcBuilder<S>(isSingleton, builder, permanent, false));
}

Future<void> removeDependencyByRoute(String routeName) async {
Expand All @@ -97,9 +97,17 @@ class GetInstance {
keysToRemove.clear();
}

bool isDependencyInit<S>({String name}) {
bool initDependencies<S>({String name}) {
String key = _getKey(S, name);
return GetConfig.routesKey.containsKey(key);
bool isInit = GetConfig._singl[key].isInit;
if (!isInit) {
startController<S>(tag: name);
GetConfig._singl[key].isInit = true;
if (GetConfig.smartManagement != SmartManagement.onlyBuilder) {
registerRouteInstance<S>(tag: name);
}
}
return true;
}

void registerRouteInstance<S>({String tag}) {
Expand All @@ -112,7 +120,7 @@ class GetInstance {
return GetConfig._singl[key].getSependency() as S;
}

void initController<S>({String tag}) {
void startController<S>({String tag}) {
String key = _getKey(S, tag);
final i = GetConfig._singl[key].getSependency();

Expand Down Expand Up @@ -146,14 +154,8 @@ class GetInstance {
/// 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;
}

if (isRegistred<S>(tag: tag)) {
FcBuilder builder = GetConfig._singl[key] as FcBuilder;
if (builder == null) {
if (tag == null) {
Expand All @@ -162,9 +164,7 @@ class GetInstance {
throw "class ${S.toString()} with tag '$tag' is not register";
}
}
if (callInit) {
initController<S>(tag: tag);
}
initDependencies<S>();

This comment has been minimized.

Copy link
@djade007

djade007 Aug 8, 2020

Contributor

The tag name is not being passed here


return GetConfig._singl[key].getSependency() as S;
} else {
Expand All @@ -175,21 +175,13 @@ class GetInstance {
print('[GETX] $S instance was created at that time');
S _value = put<S>(GetConfig._factory[key].builder() as S);

if (!isDependencyInit<S>() &&
GetConfig.smartManagement != SmartManagement.onlyBuilder) {
registerRouteInstance<S>(tag: tag);
callInit = true;
}
initDependencies<S>();

if (GetConfig.smartManagement != SmartManagement.keepFactory) {
if (!GetConfig._factory[key].fenix) {
GetConfig._factory.remove(key);
}
if (GetConfig.smartManagement != SmartManagement.keepFactory &&
!GetConfig._factory[key].fenix) {
GetConfig._factory.remove(key);
}

if (callInit) {
initController<S>(tag: tag);
}
return _value;
}
}
Expand Down Expand Up @@ -263,8 +255,9 @@ class FcBuilder<S> {
FcBuilderFunc builderFunc;
S dependency;
bool permanent = false;
bool isInit = false;

FcBuilder(this.isSingleton, this.builderFunc, this.permanent);
FcBuilder(this.isSingleton, this.builderFunc, this.permanent, this.isInit);

S getSependency() {
if (isSingleton) {
Expand Down
5 changes: 2 additions & 3 deletions lib/src/navigation/extension_navigation.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:get/src/get_interface.dart';
import 'package:get/src/instance/instance_manager.dart';
import 'package:get/src/navigation/route_manager.dart';

import 'package:get/instance_manager.dart';
import 'package:get/route_manager.dart';
import 'root/parse_route.dart';
import 'routes/bindings_interface.dart';

Expand Down
3 changes: 2 additions & 1 deletion lib/src/navigation/root/root_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ extension Trans on String {
Get.translations[Get.locale.languageCode].containsKey(this)) {
return Get.translations[Get.locale.languageCode][this];
// If there is no corresponding language or corresponding key, return the key.
} else if (Get.fallbackLocale != null && Get.translations.containsKey(
} else if (Get.fallbackLocale != null &&
Get.translations.containsKey(
"${Get.fallbackLocale.languageCode}_${Get.fallbackLocale.countryCode}") &&
Get.translations[
"${Get.fallbackLocale.languageCode}_${Get.fallbackLocale.countryCode}"]
Expand Down
4 changes: 2 additions & 2 deletions lib/src/navigation/routes/default_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import 'dart:ui' show lerpDouble;
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:get/src/navigation/route_manager.dart';
import 'package:get/route_manager.dart';
import 'package:get/src/get_main.dart';
import 'package:get/src/instance/get_instance.dart';
import 'package:get/src/utils/utils.dart';
import 'package:get/utils.dart';
import 'bindings_interface.dart';
import 'custom_transition.dart';
import 'default_transitions.dart';
Expand Down
Loading

0 comments on commit 214268a

Please sign in to comment.