Jonny Borges
Committed by GitHub

bump to 2.11.3

## [2.11.3]
- Type parameters and added docs
## [2.11.2]
- Added docs
- Improvement performance of Obx
... ...
... ... @@ -695,7 +695,7 @@ Instead of instantiating your class within the class you are using, you are inst
So you can use your controller (or class Bloc) normally
```dart
controller.fetchApi();// Rather Controller controller = Controller();
controller.fetchApi();
```
Imagine that you have navigated through numerous routes, and you need a data that was left behind in your controller, you would need a state manager combined with the Provider or Get_it, correct? Not with Get. You just need to ask Get to "find" for your controller, you don't need any additional dependencies:
... ... @@ -716,6 +716,23 @@ Get.lazyPut<Service>(()=> ApiMock());
/// ApiMock will only be called when someone uses Get.find<Service> for the first time
```
If you want to register an asynchronous instance, you can use Get.putAsync.
```dart
Get.putAsync<SharedPreferences>(() async {
final prefs = await SharedPreferences.getInstance();
await prefs.setInt('counter', 12345);
return prefs;
});
```
usage:
```dart
int count = Get.find<SharedPreferences>().getInt('counter');
print(count);
// out: 12345
}
```
To remove a instance of Get:
```dart
Get.delete<Controller>();
... ...
... ... @@ -73,14 +73,14 @@ class Get {
/// It replaces Navigator.pushNamed, but needs no context, and it doesn't have the Navigator.pushNamed
/// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior
/// of rebuilding every app after a route, use opaque = true as the parameter.
static Future<T> toNamed<T>(String page, {arguments, int id}) {
static Future<T> toNamed<T>(String page, {Object arguments, int id}) {
// if (key.currentState.mounted) // add this if appear problems on future with route navigate
// when widget don't mounted
return _get.global(id).currentState.pushNamed(page, arguments: arguments);
}
/// It replaces Navigator.pushReplacementNamed, but needs no context.
static Future<T> offNamed<T>(String page, {arguments, int id}) {
static Future<T> offNamed<T>(String page, {Object arguments, int id}) {
// if (key.currentState.mounted) // add this if appear problems on future with route navigate
// when widget don't mounted
return _get
... ... @@ -90,29 +90,32 @@ class Get {
}
/// It replaces Navigator.popUntil, but needs no context.
static void until(predicate, {int id}) {
static void until(RoutePredicate predicate, {int id}) {
// if (key.currentState.mounted) // add this if appear problems on future with route navigate
// when widget don't mounted
return _get.global(id).currentState.popUntil(predicate);
}
/// It replaces Navigator.pushAndRemoveUntil, but needs no context.
static Future<T> offUntil<T>(page, predicate, {int id}) {
static Future<T> offUntil<T>(Route<T> page, RoutePredicate predicate,
{int id}) {
// if (key.currentState.mounted) // add this if appear problems on future with route navigate
// when widget don't mounted
return _get.global(id).currentState.pushAndRemoveUntil(page, predicate);
}
/// It replaces Navigator.pushNamedAndRemoveUntil, but needs no context.
static Future<T> offNamedUntil<T>(page, predicate, {int id}) {
static Future<T> offNamedUntil<T>(String page, RoutePredicate predicate,
{int id, Object arguments}) {
return _get
.global(id)
.currentState
.pushNamedAndRemoveUntil(page, predicate);
.pushNamedAndRemoveUntil(page, predicate, arguments: arguments);
}
/// It replaces Navigator.popAndPushNamed, but needs no context.
static Future<T> offAndToNamed<T>(String page, {arguments, int id, result}) {
static Future<T> offAndToNamed<T>(String page,
{Object arguments, int id, dynamic result}) {
return _get
.global(id)
.currentState
... ... @@ -120,13 +123,13 @@ class Get {
}
/// It replaces Navigator.removeRoute, but needs no context.
static void removeRoute(route, {int id}) {
static void removeRoute(Route<dynamic> route, {int id}) {
return _get.global(id).currentState.removeRoute(route);
}
/// It replaces Navigator.pushNamedAndRemoveUntil, but needs no context.
static Future<T> offAllNamed<T>(String newRouteName,
{RoutePredicate predicate, arguments, int id}) {
{RoutePredicate predicate, Object arguments, int id}) {
var route = (Route<dynamic> rota) => false;
return _get.global(id).currentState.pushNamedAndRemoveUntil(
... ... @@ -651,6 +654,7 @@ class Get {
static Future<S> putAsync<S>(_FcBuilderFuncAsync<S> builder,
{String tag}) async {
WidgetsFlutterBinding.ensureInitialized();
return Get.put<S>(await builder(), tag: tag);
}
... ... @@ -707,7 +711,8 @@ class Get {
void removeDependencyByRoute(String routeName) async {
List<String> keysToRemove = [];
Get().routesKey.forEach((key, value) {
if (value == routeName && value != null) {
// if (value == routeName && value != null) {
if (value == routeName) {
keysToRemove.add(key);
}
});
... ... @@ -793,7 +798,6 @@ class Get {
if (callInit) {
Get().initController<S>(tag: tag);
}
return _value;
}
}
... ... @@ -998,8 +1002,6 @@ class _FcBuilder<S> {
}
}
typedef _FcBuilderFunc<S> = S Function();
typedef _FcBuilderFuncAsync<S> = Future<S> Function();
... ...
... ... @@ -32,6 +32,7 @@ class GetRouteBase<T> extends PageRoute<T> {
this.parameter,
this.binding,
this.bindings,
this.customBuildPageTransitions,
this.opaque = true,
this.transitionDuration = const Duration(milliseconds: 400),
this.popGesture,
... ... @@ -55,6 +56,8 @@ class GetRouteBase<T> extends PageRoute<T> {
/// Builds the primary contents of the route.
final Widget page;
final Widget customBuildPageTransitions;
final bool popGesture;
final Bindings binding;
... ... @@ -239,7 +242,7 @@ class GetRouteBase<T> extends PageRoute<T> {
///
/// * [CupertinoPageTransitionsBuilder], which uses this method to define a
/// [PageTransitionsBuilder] for the [PageTransitionsTheme].
static Widget buildPageTransitions<T>(
Widget buildPageTransitions<T>(
PageRoute<T> route,
BuildContext context,
bool popGesture,
... ... @@ -479,16 +482,20 @@ class GetRouteBase<T> extends PageRoute<T> {
@override
Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
return buildPageTransitions<T>(
this,
context,
popGesture ?? GetPlatform.isIOS,
animation,
secondaryAnimation,
child,
transition,
curve,
alignment);
if (customBuildPageTransitions != null) {
return customBuildPageTransitions;
} else {
return buildPageTransitions<T>(
this,
context,
popGesture ?? GetPlatform.isIOS,
animation,
secondaryAnimation,
child,
transition,
curve,
alignment);
}
}
@override
... ...
... ... @@ -10,5 +10,5 @@ enum Transition {
rightToLeftWithFade,
leftToRightWithFade,
cupertino,
// custom
custom
}
... ...
... ... @@ -3,9 +3,7 @@ class Change<T> {
final T $old;
/// Value after change
final $new;
final $new;
final ListChangeOp op;
... ... @@ -13,42 +11,29 @@ class Change<T> {
final DateTime time;
final int batch;
Change(
{this.$new,
this.$old,
this.batch,
this.op,
this.pos,
DateTime time})
Change({this.$new, this.$old, this.batch, this.op, this.pos, DateTime time})
: time = time ?? DateTime.now();
String toString() => 'Change(new: ${$new}, old: ${$old})';
Change.insert(
{this.$new, this.$old, this.batch, this.pos, DateTime time})
Change.insert({this.$new, this.$old, this.batch, this.pos, DateTime time})
: op = ListChangeOp.add,
time = time ?? new DateTime.now();
Change.set(
{this.$new, this.$old, this.batch, this.pos, DateTime time})
Change.set({this.$new, this.$old, this.batch, this.pos, DateTime time})
: op = ListChangeOp.set,
time = time ?? new DateTime.now();
Change.remove(
{this.$new, this.$old, this.batch, this.pos, DateTime time})
Change.remove({this.$new, this.$old, this.batch, this.pos, DateTime time})
: op = ListChangeOp.remove,
time = time ?? new DateTime.now();
Change.clear({this.$new, this.$old, this.batch, DateTime time})
: op = ListChangeOp.clear,
pos = null,
time = time ?? new DateTime.now();
}
typedef bool Condition();
typedef E ChildrenListComposer<S, E>(S value);
/// Change operation
enum ListChangeOp { add, remove, clear, set }
... ...
... ... @@ -134,6 +134,8 @@ class _GetBuilderState<T extends GetController> extends State<GetBuilder<T>> {
}
}
typedef ShouldRebuild<T> = bool Function(T previous, T next);
class RealState {
final StateSetter updater;
final String id;
... ...
name: get
description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
version: 2.11.2
version: 2.11.3
homepage: https://github.com/jonataslaw/get
environment:
... ...