Showing
13 changed files
with
76 additions
and
171 deletions
1 | +## [5.0.0-release-candidate-2] | ||
2 | +This version adds built-in support for animation in Flutter in an easy, clear way, and without having to create a StatefulWidget with controllers and animations. All you need to do is call the name of the animation. | ||
3 | + | ||
4 | +If you want to add a "fadeIn" effect to any widget, simply add .fadeIn() to the end of it. | ||
5 | + | ||
6 | +```dart | ||
7 | + Container( | ||
8 | + color: Colors.blue, | ||
9 | + height: 100, | ||
10 | + width: 100, | ||
11 | + ).fadeIn(), | ||
12 | +``` | ||
13 | + | ||
14 | + | ||
15 | +https://user-images.githubusercontent.com/35742643/221383556-075a0b71-1617-4a31-a3c7-1acc68732f59.mp4 | ||
16 | + | ||
17 | +Maybe you want to merge two or more animations, just concatenate them at the end of the widget. | ||
18 | + | ||
19 | +```dart | ||
20 | + Container( | ||
21 | + color: Colors.blue, | ||
22 | + height: 100, | ||
23 | + width: 100, | ||
24 | + ).fadeIn().bounce(begin: -0.8, end: 0.3), | ||
25 | +``` | ||
26 | + | ||
27 | +https://user-images.githubusercontent.com/35742643/221383613-9044c92f-7c6b-48c4-aa79-0a0c20d4068a.mp4 | ||
28 | + | ||
29 | + | ||
30 | +Creating animation sequences in Flutter is one of the most painful things to do with the framework. You need to create tons of AnimationControllers. Well, using GetX 5 you just need to tell your animation that it is sequential. Just like that. | ||
31 | + | ||
32 | +```dart | ||
33 | + const FlutterLogo(size: 110) | ||
34 | + .bounce(begin: -0.8, end: 0.4) | ||
35 | + .fadeIn() | ||
36 | + .spin(isSequential: true) | ||
37 | + .wobble(isSequential: true, begin: 0, end: 8) | ||
38 | + .flip(isSequential: true) | ||
39 | + .fadeOut(isSequential: true), | ||
40 | +``` | ||
41 | + | ||
42 | +Result: | ||
43 | + | ||
44 | + | ||
45 | +https://user-images.githubusercontent.com/35742643/221393968-20cb2411-516b-44a7-8b85-45090bece532.mp4 | ||
46 | + | ||
47 | + | ||
1 | ## [5.0.0-release-candidate] | 48 | ## [5.0.0-release-candidate] |
2 | Refactor StateManager, RouteManager and InstanceManager from scratch | 49 | Refactor StateManager, RouteManager and InstanceManager from scratch |
3 | Fixed Bugs | 50 | Fixed Bugs |
@@ -39,7 +39,7 @@ class GetHttpClient { | @@ -39,7 +39,7 @@ class GetHttpClient { | ||
39 | 39 | ||
40 | bool errorSafety = true; | 40 | bool errorSafety = true; |
41 | 41 | ||
42 | - final HttpRequestBase _httpClient; | 42 | + final IClient _httpClient; |
43 | 43 | ||
44 | final GetModifier _modifier; | 44 | final GetModifier _modifier; |
45 | 45 | ||
@@ -58,12 +58,14 @@ class GetHttpClient { | @@ -58,12 +58,14 @@ class GetHttpClient { | ||
58 | List<TrustedCertificate>? trustedCertificates, | 58 | List<TrustedCertificate>? trustedCertificates, |
59 | bool withCredentials = false, | 59 | bool withCredentials = false, |
60 | String Function(Uri url)? findProxy, | 60 | String Function(Uri url)? findProxy, |
61 | - }) : _httpClient = createHttp( | ||
62 | - allowAutoSignedCert: allowAutoSignedCert, | ||
63 | - trustedCertificates: trustedCertificates, | ||
64 | - withCredentials: withCredentials, | ||
65 | - findProxy: findProxy, | ||
66 | - ), | 61 | + IClient? customClient, |
62 | + }) : _httpClient = customClient ?? | ||
63 | + createHttp( | ||
64 | + allowAutoSignedCert: allowAutoSignedCert, | ||
65 | + trustedCertificates: trustedCertificates, | ||
66 | + withCredentials: withCredentials, | ||
67 | + findProxy: findProxy, | ||
68 | + ), | ||
67 | _modifier = GetModifier(); | 69 | _modifier = GetModifier(); |
68 | 70 | ||
69 | void addAuthenticator<T>(RequestModifier<T> auth) { | 71 | void addAuthenticator<T>(RequestModifier<T> auth) { |
@@ -86,7 +88,7 @@ class GetHttpClient { | @@ -86,7 +88,7 @@ class GetHttpClient { | ||
86 | _modifier.removeResponseModifier<T>(interceptor); | 88 | _modifier.removeResponseModifier<T>(interceptor); |
87 | } | 89 | } |
88 | 90 | ||
89 | - Uri _createUri(String? url, Map<String, dynamic>? query) { | 91 | + Uri createUri(String? url, Map<String, dynamic>? query) { |
90 | if (baseUrl != null) { | 92 | if (baseUrl != null) { |
91 | url = baseUrl! + url!; | 93 | url = baseUrl! + url!; |
92 | } | 94 | } |
@@ -155,7 +157,7 @@ class GetHttpClient { | @@ -155,7 +157,7 @@ class GetHttpClient { | ||
155 | bodyStream = _trackProgress(bodyBytes, uploadProgress); | 157 | bodyStream = _trackProgress(bodyBytes, uploadProgress); |
156 | } | 158 | } |
157 | 159 | ||
158 | - final uri = _createUri(url, query); | 160 | + final uri = createUri(url, query); |
159 | return Request<T>( | 161 | return Request<T>( |
160 | method: method, | 162 | method: method, |
161 | url: uri, | 163 | url: uri, |
@@ -277,7 +279,7 @@ class GetHttpClient { | @@ -277,7 +279,7 @@ class GetHttpClient { | ||
277 | ) { | 279 | ) { |
278 | final headers = <String, String>{}; | 280 | final headers = <String, String>{}; |
279 | _setSimpleHeaders(headers, contentType); | 281 | _setSimpleHeaders(headers, contentType); |
280 | - final uri = _createUri(url, query); | 282 | + final uri = createUri(url, query); |
281 | 283 | ||
282 | return Future.value(Request<T>( | 284 | return Future.value(Request<T>( |
283 | method: 'get', | 285 | method: 'get', |
@@ -333,7 +335,7 @@ class GetHttpClient { | @@ -333,7 +335,7 @@ class GetHttpClient { | ||
333 | ) { | 335 | ) { |
334 | final headers = <String, String>{}; | 336 | final headers = <String, String>{}; |
335 | _setSimpleHeaders(headers, contentType); | 337 | _setSimpleHeaders(headers, contentType); |
336 | - final uri = _createUri(url, query); | 338 | + final uri = createUri(url, query); |
337 | 339 | ||
338 | return Request<T>( | 340 | return Request<T>( |
339 | method: 'delete', | 341 | method: 'delete', |
@@ -525,67 +527,6 @@ class GetHttpClient { | @@ -525,67 +527,6 @@ class GetHttpClient { | ||
525 | } | 527 | } |
526 | } | 528 | } |
527 | 529 | ||
528 | - // Future<Response<T>> download<T>( | ||
529 | - // String url, | ||
530 | - // String path, { | ||
531 | - // Map<String, String> headers, | ||
532 | - // String contentType = 'application/octet-stream', | ||
533 | - // Map<String, dynamic> query, | ||
534 | - // }) async { | ||
535 | - // try { | ||
536 | - // var response = await _performRequest<T>( | ||
537 | - // () => _get<T>(url, contentType, query, null), | ||
538 | - // headers: headers, | ||
539 | - // ); | ||
540 | - // response.bodyBytes.listen((value) {}); | ||
541 | - // return response; | ||
542 | - // } on Exception catch (e) { | ||
543 | - // if (!errorSafety) { | ||
544 | - // throw GetHttpException(e.toString()); | ||
545 | - // } | ||
546 | - // return Future.value(Response<T>( | ||
547 | - // statusText: 'Can not connect to server. Reason: $e', | ||
548 | - // )); | ||
549 | - // } | ||
550 | - | ||
551 | - // int byteCount = 0; | ||
552 | - // int totalBytes = httpResponse.contentLength; | ||
553 | - | ||
554 | - // Directory appDocDir = await getApplicationDocumentsDirectory(); | ||
555 | - // String appDocPath = appDocDir.path; | ||
556 | - | ||
557 | - // File file = File(path); | ||
558 | - | ||
559 | - // var raf = file.openSync(mode: FileMode.write); | ||
560 | - | ||
561 | - // Completer completer = Completer<String>(); | ||
562 | - | ||
563 | - // httpResponse.listen( | ||
564 | - // (data) { | ||
565 | - // byteCount += data.length; | ||
566 | - | ||
567 | - // raf.writeFromSync(data); | ||
568 | - | ||
569 | - // if (onDownloadProgress != null) { | ||
570 | - // onDownloadProgress(byteCount, totalBytes); | ||
571 | - // } | ||
572 | - // }, | ||
573 | - // onDone: () { | ||
574 | - // raf.closeSync(); | ||
575 | - | ||
576 | - // completer.complete(file.path); | ||
577 | - // }, | ||
578 | - // onError: (e) { | ||
579 | - // raf.closeSync(); | ||
580 | - // file.deleteSync(); | ||
581 | - // completer.completeError(e); | ||
582 | - // }, | ||
583 | - // cancelOnError: true, | ||
584 | - // ); | ||
585 | - | ||
586 | - // return completer.future; | ||
587 | - // } | ||
588 | - | ||
589 | Future<Response<T>> delete<T>(String url, | 530 | Future<Response<T>> delete<T>(String url, |
590 | {Map<String, String>? headers, | 531 | {Map<String, String>? headers, |
591 | String? contentType, | 532 | String? contentType, |
@@ -9,8 +9,8 @@ import '../../response/response.dart'; | @@ -9,8 +9,8 @@ import '../../response/response.dart'; | ||
9 | import '../interface/request_base.dart'; | 9 | import '../interface/request_base.dart'; |
10 | import '../utils/body_decoder.dart'; | 10 | import '../utils/body_decoder.dart'; |
11 | 11 | ||
12 | -/// A `dart:html` implementation of `HttpRequestBase`. | ||
13 | -class HttpRequestImpl implements HttpRequestBase { | 12 | +/// A `dart:html` implementation of `IClient`. |
13 | +class HttpRequestImpl implements IClient { | ||
14 | HttpRequestImpl({ | 14 | HttpRequestImpl({ |
15 | bool allowAutoSignedCert = true, | 15 | bool allowAutoSignedCert = true, |
16 | List<TrustedCertificate>? trustedCertificates, | 16 | List<TrustedCertificate>? trustedCertificates, |
@@ -51,7 +51,7 @@ class HttpRequestImpl implements HttpRequestBase { | @@ -51,7 +51,7 @@ class HttpRequestImpl implements HttpRequestBase { | ||
51 | var reader = FileReader(); | 51 | var reader = FileReader(); |
52 | 52 | ||
53 | reader.onLoad.first.then((_) async { | 53 | reader.onLoad.first.then((_) async { |
54 | - var bodyBytes = BodyBytesStream.fromBytes(reader.result as List<int>); | 54 | + var bodyBytes = (reader.result as List<int>).toStream(); |
55 | 55 | ||
56 | final stringBody = | 56 | final stringBody = |
57 | await bodyBytesToString(bodyBytes, xhr.responseHeaders); | 57 | await bodyBytesToString(bodyBytes, xhr.responseHeaders); |
@@ -2,7 +2,7 @@ import '../../request/request.dart'; | @@ -2,7 +2,7 @@ import '../../request/request.dart'; | ||
2 | import '../../response/response.dart'; | 2 | import '../../response/response.dart'; |
3 | 3 | ||
4 | /// Abstract interface of [HttpRequestImpl]. | 4 | /// Abstract interface of [HttpRequestImpl]. |
5 | -abstract class HttpRequestBase { | 5 | +abstract class IClient { |
6 | /// Sends an HTTP [Request]. | 6 | /// Sends an HTTP [Request]. |
7 | Future<Response<T>> send<T>(Request<T> request); | 7 | Future<Response<T>> send<T>(Request<T> request); |
8 | 8 |
@@ -8,8 +8,8 @@ import '../../response/response.dart'; | @@ -8,8 +8,8 @@ import '../../response/response.dart'; | ||
8 | import '../interface/request_base.dart'; | 8 | import '../interface/request_base.dart'; |
9 | import '../utils/body_decoder.dart'; | 9 | import '../utils/body_decoder.dart'; |
10 | 10 | ||
11 | -/// A `dart:io` implementation of `HttpRequestBase`. | ||
12 | -class HttpRequestImpl extends HttpRequestBase { | 11 | +/// A `dart:io` implementation of `IClient`. |
12 | +class HttpRequestImpl extends IClient { | ||
13 | io.HttpClient? _httpClient; | 13 | io.HttpClient? _httpClient; |
14 | io.SecurityContext? _securityContext; | 14 | io.SecurityContext? _securityContext; |
15 | 15 |
@@ -5,7 +5,7 @@ import '../utils/body_decoder.dart'; | @@ -5,7 +5,7 @@ import '../utils/body_decoder.dart'; | ||
5 | 5 | ||
6 | typedef MockClientHandler = Future<Response> Function(Request request); | 6 | typedef MockClientHandler = Future<Response> Function(Request request); |
7 | 7 | ||
8 | -class MockClient extends HttpRequestBase { | 8 | +class MockClient extends IClient { |
9 | /// The handler for than transforms request on response | 9 | /// The handler for than transforms request on response |
10 | final MockClientHandler _handler; | 10 | final MockClientHandler _handler; |
11 | 11 | ||
@@ -16,7 +16,7 @@ class MockClient extends HttpRequestBase { | @@ -16,7 +16,7 @@ class MockClient extends HttpRequestBase { | ||
16 | @override | 16 | @override |
17 | Future<Response<T>> send<T>(Request<T> request) async { | 17 | Future<Response<T>> send<T>(Request<T> request) async { |
18 | var requestBody = await request.bodyBytes.toBytes(); | 18 | var requestBody = await request.bodyBytes.toBytes(); |
19 | - var bodyBytes = BodyBytesStream.fromBytes(requestBody); | 19 | + var bodyBytes = requestBody.toStream(); |
20 | 20 | ||
21 | var response = await _handler(request); | 21 | var response = await _handler(request); |
22 | 22 |
@@ -3,7 +3,7 @@ import '../../request/request.dart'; | @@ -3,7 +3,7 @@ import '../../request/request.dart'; | ||
3 | import '../../response/response.dart'; | 3 | import '../../response/response.dart'; |
4 | import '../interface/request_base.dart'; | 4 | import '../interface/request_base.dart'; |
5 | 5 | ||
6 | -class HttpRequestImpl extends HttpRequestBase { | 6 | +class HttpRequestImpl extends IClient { |
7 | HttpRequestImpl({ | 7 | HttpRequestImpl({ |
8 | bool allowAutoSignedCert = true, | 8 | bool allowAutoSignedCert = true, |
9 | List<TrustedCertificate>? trustedCertificates, | 9 | List<TrustedCertificate>? trustedCertificates, |
1 | import '../http/stub/file_decoder_stub.dart' | 1 | import '../http/stub/file_decoder_stub.dart' |
2 | if (dart.library.html) '../http/html/file_decoder_html.dart' | 2 | if (dart.library.html) '../http/html/file_decoder_html.dart' |
3 | if (dart.library.io) '../http/io/file_decoder_io.dart'; | 3 | if (dart.library.io) '../http/io/file_decoder_io.dart'; |
4 | - | ||
5 | import '../request/request.dart'; | 4 | import '../request/request.dart'; |
6 | 5 | ||
7 | class MultipartFile { | 6 | class MultipartFile { |
@@ -11,7 +10,7 @@ class MultipartFile { | @@ -11,7 +10,7 @@ class MultipartFile { | ||
11 | this.contentType = 'application/octet-stream', | 10 | this.contentType = 'application/octet-stream', |
12 | }) : _bytes = fileToBytes(data) { | 11 | }) : _bytes = fileToBytes(data) { |
13 | _length = _bytes.length; | 12 | _length = _bytes.length; |
14 | - _stream = BodyBytesStream.fromBytes(_bytes); | 13 | + _stream = _bytes.toStream(); |
15 | } | 14 | } |
16 | 15 | ||
17 | final List<int> _bytes; | 16 | final List<int> _bytes; |
@@ -68,7 +68,7 @@ class Request<T> { | @@ -68,7 +68,7 @@ class Request<T> { | ||
68 | return Request._( | 68 | return Request._( |
69 | url: url, | 69 | url: url, |
70 | method: method, | 70 | method: method, |
71 | - bodyBytes: bodyBytes ??= BodyBytesStream.fromBytes(const []), | 71 | + bodyBytes: bodyBytes ??= <int>[].toStream(), |
72 | headers: Map.from(headers), | 72 | headers: Map.from(headers), |
73 | followRedirects: followRedirects, | 73 | followRedirects: followRedirects, |
74 | maxRedirects: maxRedirects, | 74 | maxRedirects: maxRedirects, |
@@ -113,9 +113,11 @@ class Request<T> { | @@ -113,9 +113,11 @@ class Request<T> { | ||
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | -extension BodyBytesStream on Stream<List<int>> { | ||
117 | - static Stream<List<int>> fromBytes(List<int> bytes) => Stream.value(bytes); | 116 | +extension StreamExt on List<int> { |
117 | + Stream<List<int>> toStream() => Stream.value(this).asBroadcastStream(); | ||
118 | +} | ||
118 | 119 | ||
120 | +extension BodyBytesStream on Stream<List<int>> { | ||
119 | Future<Uint8List> toBytes() { | 121 | Future<Uint8List> toBytes() { |
120 | var completer = Completer<Uint8List>(); | 122 | var completer = Completer<Uint8List>(); |
121 | var sink = ByteConversionSink.withCallback( | 123 | var sink = ByteConversionSink.withCallback( |
@@ -10,85 +10,6 @@ typedef OnTap = void Function(GetSnackBar snack); | @@ -10,85 +10,6 @@ typedef OnTap = void Function(GetSnackBar snack); | ||
10 | 10 | ||
11 | typedef SnackbarStatusCallback = void Function(SnackbarStatus? status); | 11 | typedef SnackbarStatusCallback = void Function(SnackbarStatus? status); |
12 | 12 | ||
13 | -@Deprecated('use GetSnackBar') | ||
14 | -class GetBar extends GetSnackBar { | ||
15 | - const GetBar({ | ||
16 | - Key? key, | ||
17 | - String? title, | ||
18 | - String? message, | ||
19 | - Widget? titleText, | ||
20 | - Widget? messageText, | ||
21 | - Widget? icon, | ||
22 | - bool shouldIconPulse = true, | ||
23 | - double? maxWidth, | ||
24 | - EdgeInsets margin = const EdgeInsets.all(0.0), | ||
25 | - EdgeInsets padding = const EdgeInsets.all(16), | ||
26 | - double borderRadius = 0.0, | ||
27 | - Color? borderColor, | ||
28 | - double borderWidth = 1.0, | ||
29 | - Color backgroundColor = const Color(0xFF303030), | ||
30 | - Color? leftBarIndicatorColor, | ||
31 | - List<BoxShadow>? boxShadows, | ||
32 | - Gradient? backgroundGradient, | ||
33 | - Widget? mainButton, | ||
34 | - OnTap? onTap, | ||
35 | - Duration? duration, | ||
36 | - bool isDismissible = true, | ||
37 | - DismissDirection? dismissDirection, | ||
38 | - bool showProgressIndicator = false, | ||
39 | - AnimationController? progressIndicatorController, | ||
40 | - Color? progressIndicatorBackgroundColor, | ||
41 | - Animation<Color>? progressIndicatorValueColor, | ||
42 | - SnackPosition snackPosition = SnackPosition.bottom, | ||
43 | - SnackStyle snackStyle = SnackStyle.floating, | ||
44 | - Curve forwardAnimationCurve = Curves.easeOutCirc, | ||
45 | - Curve reverseAnimationCurve = Curves.easeOutCirc, | ||
46 | - Duration animationDuration = const Duration(seconds: 1), | ||
47 | - double barBlur = 0.0, | ||
48 | - double overlayBlur = 0.0, | ||
49 | - Color overlayColor = Colors.transparent, | ||
50 | - Form? userInputForm, | ||
51 | - SnackbarStatusCallback? snackbarStatus, | ||
52 | - }) : super( | ||
53 | - key: key, | ||
54 | - title: title, | ||
55 | - message: message, | ||
56 | - titleText: titleText, | ||
57 | - messageText: messageText, | ||
58 | - icon: icon, | ||
59 | - shouldIconPulse: shouldIconPulse, | ||
60 | - maxWidth: maxWidth, | ||
61 | - margin: margin, | ||
62 | - padding: padding, | ||
63 | - borderRadius: borderRadius, | ||
64 | - borderColor: borderColor, | ||
65 | - borderWidth: borderWidth, | ||
66 | - backgroundColor: backgroundColor, | ||
67 | - leftBarIndicatorColor: leftBarIndicatorColor, | ||
68 | - boxShadows: boxShadows, | ||
69 | - backgroundGradient: backgroundGradient, | ||
70 | - mainButton: mainButton, | ||
71 | - onTap: onTap, | ||
72 | - duration: duration, | ||
73 | - isDismissible: isDismissible, | ||
74 | - dismissDirection: dismissDirection, | ||
75 | - showProgressIndicator: showProgressIndicator, | ||
76 | - progressIndicatorController: progressIndicatorController, | ||
77 | - progressIndicatorBackgroundColor: progressIndicatorBackgroundColor, | ||
78 | - progressIndicatorValueColor: progressIndicatorValueColor, | ||
79 | - snackPosition: snackPosition, | ||
80 | - snackStyle: snackStyle, | ||
81 | - forwardAnimationCurve: forwardAnimationCurve, | ||
82 | - reverseAnimationCurve: reverseAnimationCurve, | ||
83 | - animationDuration: animationDuration, | ||
84 | - barBlur: barBlur, | ||
85 | - overlayBlur: overlayBlur, | ||
86 | - overlayColor: overlayColor, | ||
87 | - userInputForm: userInputForm, | ||
88 | - snackbarStatus: snackbarStatus, | ||
89 | - ); | ||
90 | -} | ||
91 | - | ||
92 | class GetSnackBar extends StatefulWidget { | 13 | class GetSnackBar extends StatefulWidget { |
93 | /// A callback for you to listen to the different Snack status | 14 | /// A callback for you to listen to the different Snack status |
94 | final SnackbarStatusCallback? snackbarStatus; | 15 | final SnackbarStatusCallback? snackbarStatus; |
@@ -3,10 +3,6 @@ import '../get_utils/get_utils.dart'; | @@ -3,10 +3,6 @@ import '../get_utils/get_utils.dart'; | ||
3 | extension GetDynamicUtils on dynamic { | 3 | extension GetDynamicUtils on dynamic { |
4 | bool? get isBlank => GetUtils.isBlank(this); | 4 | bool? get isBlank => GetUtils.isBlank(this); |
5 | 5 | ||
6 | - @Deprecated( | ||
7 | - 'isNullOrBlank is deprecated and cannot be used, use "isBlank" instead') | ||
8 | - bool? get isNullOrBlank => GetUtils.isNullOrBlank(this); | ||
9 | - | ||
10 | void printError( | 6 | void printError( |
11 | {String info = '', Function logFunction = GetUtils.printFunction}) => | 7 | {String info = '', Function logFunction = GetUtils.printFunction}) => |
12 | // ignore: unnecessary_this | 8 | // ignore: unnecessary_this |
1 | name: get | 1 | name: get |
2 | description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX. | 2 | description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX. |
3 | -version: 5.0.0-release-candidate | 3 | +version: 5.0.0-release-candidate-2 |
4 | homepage: https://github.com/jonataslaw/getx | 4 | homepage: https://github.com/jonataslaw/getx |
5 | 5 | ||
6 | environment: | 6 | environment: |
-
Please register or login to post a comment