Showing
7 changed files
with
65 additions
and
27 deletions
| 1 | +## [3.1.2] | ||
| 2 | +- Expose GetInstance | ||
| 3 | + | ||
| 4 | +## [3.1.1] | ||
| 5 | +- Improvement .obs methods | ||
| 6 | + | ||
| 1 | ## [3.1.0] | 7 | ## [3.1.0] |
| 2 | - Added extensions to GetUtils and fix typo on GetUtils.isEmail (@stefandevo) | 8 | - Added extensions to GetUtils and fix typo on GetUtils.isEmail (@stefandevo) |
| 3 | - Added .gitignore file (@hdeyana) | 9 | - Added .gitignore file (@hdeyana) |
| @@ -24,5 +24,7 @@ export 'src/routes/observers/route_observer.dart'; | @@ -24,5 +24,7 @@ export 'src/routes/observers/route_observer.dart'; | ||
| 24 | export 'src/routes/transitions_type.dart'; | 24 | export 'src/routes/transitions_type.dart'; |
| 25 | export 'src/platform/platform.dart'; | 25 | export 'src/platform/platform.dart'; |
| 26 | export 'src/instance/extension_instance.dart'; | 26 | export 'src/instance/extension_instance.dart'; |
| 27 | +export 'src/instance/get_instance.dart'; | ||
| 28 | +export 'src/typedefs/typedefs.dart'; | ||
| 27 | export 'src/routes/custom_transition.dart'; | 29 | export 'src/routes/custom_transition.dart'; |
| 28 | export 'src/context_extensions/extensions.dart'; | 30 | export 'src/context_extensions/extensions.dart'; |
| @@ -51,18 +51,6 @@ class _RxImpl<T> implements RxInterface<T> { | @@ -51,18 +51,6 @@ class _RxImpl<T> implements RxInterface<T> { | ||
| 51 | Stream<R> map<R>(R mapper(T data)) => stream.map(mapper); | 51 | Stream<R> map<R>(R mapper(T data)) => stream.map(mapper); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | -class RxString<String> extends _RxImpl<String> { | ||
| 55 | - RxString([String initial]) { | ||
| 56 | - _value = initial; | ||
| 57 | - } | ||
| 58 | -} | ||
| 59 | - | ||
| 60 | -class RxInt<int> extends _RxImpl<int> { | ||
| 61 | - RxInt([int initial]) { | ||
| 62 | - _value = initial; | ||
| 63 | - } | ||
| 64 | -} | ||
| 65 | - | ||
| 66 | class RxMap<K, V> extends RxInterface implements Map<K, V> { | 54 | class RxMap<K, V> extends RxInterface implements Map<K, V> { |
| 67 | RxMap([Map<K, V> initial]) { | 55 | RxMap([Map<K, V> initial]) { |
| 68 | _value = initial; | 56 | _value = initial; |
| @@ -414,24 +402,36 @@ typedef bool Condition(); | @@ -414,24 +402,36 @@ typedef bool Condition(); | ||
| 414 | 402 | ||
| 415 | typedef E ChildrenListComposer<S, E>(S value); | 403 | typedef E ChildrenListComposer<S, E>(S value); |
| 416 | 404 | ||
| 417 | -class RxBool<bool> extends _RxImpl<bool> { | 405 | +class RxBool extends _RxImpl<bool> { |
| 418 | RxBool([bool initial]) { | 406 | RxBool([bool initial]) { |
| 419 | _value = initial; | 407 | _value = initial; |
| 420 | } | 408 | } |
| 421 | } | 409 | } |
| 422 | 410 | ||
| 423 | -class RxDouble<double> extends _RxImpl<double> { | 411 | +class RxDouble extends _RxImpl<double> { |
| 424 | RxDouble([double initial]) { | 412 | RxDouble([double initial]) { |
| 425 | _value = initial; | 413 | _value = initial; |
| 426 | } | 414 | } |
| 427 | } | 415 | } |
| 428 | 416 | ||
| 429 | -class RxNum<num> extends _RxImpl<num> { | 417 | +class RxNum extends _RxImpl<num> { |
| 430 | RxNum([num initial]) { | 418 | RxNum([num initial]) { |
| 431 | _value = initial; | 419 | _value = initial; |
| 432 | } | 420 | } |
| 433 | } | 421 | } |
| 434 | 422 | ||
| 423 | +class RxString extends _RxImpl<String> { | ||
| 424 | + RxString([String initial]) { | ||
| 425 | + _value = initial; | ||
| 426 | + } | ||
| 427 | +} | ||
| 428 | + | ||
| 429 | +class RxInt extends _RxImpl<int> { | ||
| 430 | + RxInt([int initial]) { | ||
| 431 | + _value = initial; | ||
| 432 | + } | ||
| 433 | +} | ||
| 434 | + | ||
| 435 | class Rx<T> extends _RxImpl<T> { | 435 | class Rx<T> extends _RxImpl<T> { |
| 436 | Rx([T initial]) { | 436 | Rx([T initial]) { |
| 437 | _value = initial; | 437 | _value = initial; |
| @@ -439,25 +439,25 @@ class Rx<T> extends _RxImpl<T> { | @@ -439,25 +439,25 @@ class Rx<T> extends _RxImpl<T> { | ||
| 439 | } | 439 | } |
| 440 | 440 | ||
| 441 | extension StringExtension on String { | 441 | extension StringExtension on String { |
| 442 | - RxString<String> get obs => RxString(this); | 442 | + RxString get obs => RxString(this); |
| 443 | } | 443 | } |
| 444 | 444 | ||
| 445 | extension IntExtension on int { | 445 | extension IntExtension on int { |
| 446 | - RxInt<int> get obs => RxInt(this); | 446 | + RxInt get obs => RxInt(this); |
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | extension DoubleExtension on double { | 449 | extension DoubleExtension on double { |
| 450 | - RxDouble<double> get obs => RxDouble(this); | 450 | + RxDouble get obs => RxDouble(this); |
| 451 | } | 451 | } |
| 452 | 452 | ||
| 453 | extension BoolExtension on bool { | 453 | extension BoolExtension on bool { |
| 454 | - RxBool<bool> get obs => RxBool(this); | 454 | + RxBool get obs => RxBool(this); |
| 455 | } | 455 | } |
| 456 | 456 | ||
| 457 | extension MapExtension<K, V> on Map<K, V> { | 457 | extension MapExtension<K, V> on Map<K, V> { |
| 458 | RxMap<K, V> get obs { | 458 | RxMap<K, V> get obs { |
| 459 | if (this != null) | 459 | if (this != null) |
| 460 | - return RxMap<K, V>({})..addAll(this); | 460 | + return RxMap<K, V>(<K, V>{})..addAll(this); |
| 461 | else | 461 | else |
| 462 | return RxMap<K, V>(null); | 462 | return RxMap<K, V>(null); |
| 463 | } | 463 | } |
| @@ -466,12 +466,12 @@ extension MapExtension<K, V> on Map<K, V> { | @@ -466,12 +466,12 @@ extension MapExtension<K, V> on Map<K, V> { | ||
| 466 | extension ListExtension<E> on List<E> { | 466 | extension ListExtension<E> on List<E> { |
| 467 | RxList<E> get obs { | 467 | RxList<E> get obs { |
| 468 | if (this != null) | 468 | if (this != null) |
| 469 | - return RxList<E>([])..addAllNonNull(this); | 469 | + return RxList<E>(<E>[])..addAllNonNull(this); |
| 470 | else | 470 | else |
| 471 | return RxList<E>(null); | 471 | return RxList<E>(null); |
| 472 | } | 472 | } |
| 473 | } | 473 | } |
| 474 | 474 | ||
| 475 | -extension ObjectExtension on Object { | ||
| 476 | - Rx<Object> get obs => Rx(this); | 475 | +extension RxT<T> on T { |
| 476 | + Rx<T> get obs => Rx(this); | ||
| 477 | } | 477 | } |
| @@ -50,12 +50,14 @@ class _ObxState extends State<Obx> { | @@ -50,12 +50,14 @@ class _ObxState extends State<Obx> { | ||
| 50 | super.dispose(); | 50 | super.dispose(); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | - @override | ||
| 54 | - Widget build(BuildContext context) { | 53 | + Widget get notifyChilds { |
| 55 | final observer = getObs; | 54 | final observer = getObs; |
| 56 | getObs = _observer; | 55 | getObs = _observer; |
| 57 | final result = widget.builder(); | 56 | final result = widget.builder(); |
| 58 | getObs = observer; | 57 | getObs = observer; |
| 59 | return result; | 58 | return result; |
| 60 | } | 59 | } |
| 60 | + | ||
| 61 | + @override | ||
| 62 | + Widget build(BuildContext context) => notifyChilds; | ||
| 61 | } | 63 | } |
| 1 | +import 'dart:collection'; | ||
| 1 | import 'package:flutter/widgets.dart'; | 2 | import 'package:flutter/widgets.dart'; |
| 2 | import 'package:get/src/instance/get_instance.dart'; | 3 | import 'package:get/src/instance/get_instance.dart'; |
| 3 | import 'package:get/src/root/smart_management.dart'; | 4 | import 'package:get/src/root/smart_management.dart'; |
| 4 | import 'package:get/src/rx/rx_interface.dart'; | 5 | import 'package:get/src/rx/rx_interface.dart'; |
| 5 | 6 | ||
| 6 | class GetxController extends DisposableInterface { | 7 | class GetxController extends DisposableInterface { |
| 7 | - final List<Updater> _updaters = []; | 8 | + final HashSet<Updater> _updaters = HashSet<Updater>(); |
| 8 | 9 | ||
| 9 | /// Update GetBuilder with update(); | 10 | /// Update GetBuilder with update(); |
| 10 | void update([List<String> ids, bool condition = true]) { | 11 | void update([List<String> ids, bool condition = true]) { |
| 1 | import 'package:flutter/widgets.dart'; | 1 | import 'package:flutter/widgets.dart'; |
| 2 | import 'package:get/src/instance/get_instance.dart'; | 2 | import 'package:get/src/instance/get_instance.dart'; |
| 3 | 3 | ||
| 4 | +abstract class GetWidget<T> extends StatelessWidget { | ||
| 5 | + const GetWidget({Key key}) : super(key: key); | ||
| 6 | + T get controller => GetInstance().find(); | ||
| 7 | + | ||
| 8 | + @override | ||
| 9 | + Widget build(BuildContext context); | ||
| 10 | +} | ||
| 11 | + | ||
| 4 | abstract class GetView<T> extends StatelessWidget { | 12 | abstract class GetView<T> extends StatelessWidget { |
| 5 | const GetView({Key key}) : super(key: key); | 13 | const GetView({Key key}) : super(key: key); |
| 6 | T get controller => GetInstance().find(); | 14 | T get controller => GetInstance().find(); |
| @@ -8,3 +16,22 @@ abstract class GetView<T> extends StatelessWidget { | @@ -8,3 +16,22 @@ abstract class GetView<T> extends StatelessWidget { | ||
| 8 | @override | 16 | @override |
| 9 | Widget build(BuildContext context); | 17 | Widget build(BuildContext context); |
| 10 | } | 18 | } |
| 19 | + | ||
| 20 | +// abstract class GetView<A, B> extends StatelessWidget { | ||
| 21 | +// const GetView({Key key}) : super(key: key); | ||
| 22 | +// A get controller => GetInstance().find(); | ||
| 23 | +// B get controller2 => GetInstance().find(); | ||
| 24 | + | ||
| 25 | +// @override | ||
| 26 | +// Widget build(BuildContext context); | ||
| 27 | +// } | ||
| 28 | + | ||
| 29 | +// abstract class GetView2<A, B, C> extends StatelessWidget { | ||
| 30 | +// const GetView2({Key key}) : super(key: key); | ||
| 31 | +// A get controller => GetInstance().find(); | ||
| 32 | +// B get controller2 => GetInstance().find(); | ||
| 33 | +// C get controller3 => GetInstance().find(); | ||
| 34 | + | ||
| 35 | +// @override | ||
| 36 | +// Widget build(BuildContext context); | ||
| 37 | +// } |
| 1 | name: get | 1 | name: get |
| 2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get. | 2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get. |
| 3 | -version: 3.1.0 | 3 | +version: 3.1.2 |
| 4 | homepage: https://github.com/jonataslaw/get | 4 | homepage: https://github.com/jonataslaw/get |
| 5 | 5 | ||
| 6 | environment: | 6 | environment: |
-
Please register or login to post a comment