Jonny Borges

solving dart migrate errors

Showing 41 changed files with 1011 additions and 1017 deletions

Too many changes to show.

To preserve performance only 41 of 41+ files are displayed.

... ... @@ -13,74 +13,74 @@ export 'http/src/response/response.dart';
export 'sockets/sockets.dart';
abstract class GetConnectInterface with GetLifeCycleBase {
List<GetSocket> sockets;
List<GetSocket>? sockets;
GetHttpClient get httpClient;
Future<Response<T>> get<T>(
String url, {
Map<String, String> headers,
String contentType,
Map<String, dynamic> query,
Decoder<T> decoder,
Map<String, String>? headers,
String? contentType,
Map<String, dynamic>? query,
Decoder<T>? decoder,
});
Future<Response<T>> request<T>(
String url,
String method, {
dynamic body,
String contentType,
Map<String, String> headers,
Map<String, dynamic> query,
Decoder<T> decoder,
String? contentType,
Map<String, String>? headers,
Map<String, dynamic>? query,
Decoder<T>? decoder,
});
Future<Response<T>> post<T>(
String url,
dynamic body, {
String contentType,
Map<String, String> headers,
Map<String, dynamic> query,
Decoder<T> decoder,
String? contentType,
Map<String, String>? headers,
Map<String, dynamic>? query,
Decoder<T>? decoder,
});
Future<Response<T>> put<T>(
String url,
dynamic body, {
String contentType,
Map<String, String> headers,
Map<String, dynamic> query,
Decoder<T> decoder,
String? contentType,
Map<String, String>? headers,
Map<String, dynamic>? query,
Decoder<T>? decoder,
});
Future<Response<T>> delete<T>(
String url, {
Map<String, String> headers,
String contentType,
Map<String, dynamic> query,
Decoder<T> decoder,
Map<String, String>? headers,
String? contentType,
Map<String, dynamic>? query,
Decoder<T>? decoder,
});
Future<Response<T>> patch<T>(
String url,
dynamic body, {
String contentType,
Map<String, String> headers,
Map<String, dynamic> query,
Decoder<T> decoder,
Progress uploadProgress,
String? contentType,
Map<String, String>? headers,
Map<String, dynamic>? query,
Decoder<T>? decoder,
Progress? uploadProgress,
});
Future<GraphQLResponse<T>> query<T>(
String query, {
String url,
Map<String, dynamic> variables,
Map<String, String> headers,
String? url,
Map<String, dynamic>? variables,
Map<String, String>? headers,
});
Future<GraphQLResponse<T>> mutation<T>(
String mutation, {
String url,
Map<String, dynamic> variables,
Map<String, String> headers,
String? url,
Map<String, dynamic>? variables,
Map<String, String>? headers,
});
GetSocket socket(
... ... @@ -103,16 +103,16 @@ class GetConnect extends GetConnectInterface {
bool allowAutoSignedCert;
String userAgent;
String baseUrl;
String? baseUrl;
String defaultContentType = 'application/json; charset=utf-8';
bool followRedirects;
int maxRedirects;
int maxAuthRetries;
Decoder defaultDecoder;
Decoder? defaultDecoder;
Duration timeout;
List<TrustedCertificate> trustedCertificates;
GetHttpClient _httpClient;
List<GetSocket> _sockets;
List<TrustedCertificate>? trustedCertificates;
GetHttpClient? _httpClient;
List<GetSocket>? _sockets;
@override
List<GetSocket> get sockets => _sockets ??= <GetSocket>[];
... ... @@ -132,10 +132,10 @@ class GetConnect extends GetConnectInterface {
@override
Future<Response<T>> get<T>(
String url, {
Map<String, String> headers,
String contentType,
Map<String, dynamic> query,
Decoder<T> decoder,
Map<String, String>? headers,
String? contentType,
Map<String, dynamic>? query,
Decoder<T>? decoder,
}) {
_checkIfDisposed();
return httpClient.get<T>(
... ... @@ -149,13 +149,13 @@ class GetConnect extends GetConnectInterface {
@override
Future<Response<T>> post<T>(
String url,
String? url,
dynamic body, {
String contentType,
Map<String, String> headers,
Map<String, dynamic> query,
Decoder<T> decoder,
Progress uploadProgress,
String? contentType,
Map<String, String>? headers,
Map<String, dynamic>? query,
Decoder<T>? decoder,
Progress? uploadProgress,
}) {
_checkIfDisposed();
return httpClient.post<T>(
... ... @@ -173,11 +173,11 @@ class GetConnect extends GetConnectInterface {
Future<Response<T>> put<T>(
String url,
dynamic body, {
String contentType,
Map<String, String> headers,
Map<String, dynamic> query,
Decoder<T> decoder,
Progress uploadProgress,
String? contentType,
Map<String, String>? headers,
Map<String, dynamic>? query,
Decoder<T>? decoder,
Progress? uploadProgress,
}) {
_checkIfDisposed();
return httpClient.put<T>(
... ... @@ -195,11 +195,11 @@ class GetConnect extends GetConnectInterface {
Future<Response<T>> patch<T>(
String url,
dynamic body, {
String contentType,
Map<String, String> headers,
Map<String, dynamic> query,
Decoder<T> decoder,
Progress uploadProgress,
String? contentType,
Map<String, String>? headers,
Map<String, dynamic>? query,
Decoder<T>? decoder,
Progress? uploadProgress,
}) {
_checkIfDisposed();
return httpClient.patch<T>(
... ... @@ -218,11 +218,11 @@ class GetConnect extends GetConnectInterface {
String url,
String method, {
dynamic body,
String contentType,
Map<String, String> headers,
Map<String, dynamic> query,
Decoder<T> decoder,
Progress uploadProgress,
String? contentType,
Map<String, String>? headers,
Map<String, dynamic>? query,
Decoder<T>? decoder,
Progress? uploadProgress,
}) {
_checkIfDisposed();
return httpClient.request<T>(
... ... @@ -240,10 +240,10 @@ class GetConnect extends GetConnectInterface {
@override
Future<Response<T>> delete<T>(
String url, {
Map<String, String> headers,
String contentType,
Map<String, dynamic> query,
Decoder<T> decoder,
Map<String, String>? headers,
String? contentType,
Map<String, dynamic>? query,
Decoder<T>? decoder,
}) {
_checkIfDisposed();
return httpClient.delete(
... ... @@ -267,9 +267,9 @@ class GetConnect extends GetConnectInterface {
return _socket;
}
String _concatUrl(String url) {
String? _concatUrl(String? url) {
if (url == null) return baseUrl;
return baseUrl == null ? url : baseUrl + url;
return baseUrl == null ? url : baseUrl! + url;
}
/// query allow made GraphQL raw querys
... ... @@ -294,9 +294,9 @@ class GetConnect extends GetConnectInterface {
@override
Future<GraphQLResponse<T>> query<T>(
String query, {
String url,
Map<String, dynamic> variables,
Map<String, String> headers,
String? url,
Map<String, dynamic>? variables,
Map<String, String>? headers,
}) async {
try {
final res = await post(
... ... @@ -316,7 +316,7 @@ class GetConnect extends GetConnectInterface {
))
.toList());
}
return GraphQLResponse<T>(body: res.body['data'] as T);
return GraphQLResponse<T>(body: res.body['data'] as T?);
} on Exception catch (_) {
return GraphQLResponse<T>(graphQLErrors: [
GraphQLError(
... ... @@ -330,9 +330,9 @@ class GetConnect extends GetConnectInterface {
@override
Future<GraphQLResponse<T>> mutation<T>(
String mutation, {
String url,
Map<String, dynamic> variables,
Map<String, String> headers,
String? url,
Map<String, dynamic>? variables,
Map<String, String>? headers,
}) async {
try {
final res = await post(
... ... @@ -352,7 +352,7 @@ class GetConnect extends GetConnectInterface {
))
.toList());
}
return GraphQLResponse<T>(body: res.body['data'] as T);
return GraphQLResponse<T>(body: res.body['data'] as T?);
} on Exception catch (_) {
return GraphQLResponse<T>(graphQLErrors: [
GraphQLError(
... ...
class GetHttpException implements Exception {
final String message;
final Uri uri;
final Uri? uri;
GetHttpException(this.message, [this.uri]);
... ... @@ -11,8 +11,8 @@ class GetHttpException implements Exception {
class GraphQLError {
GraphQLError({this.code, this.message});
final String message;
final String code;
final String? message;
final String? code;
@override
String toString() => 'GETCONNECT ERROR:\n\tcode:$code\n\tmessage:$message';
... ...
... ... @@ -20,7 +20,7 @@ typedef Progress = Function(double percent);
class GetHttpClient {
String userAgent;
String baseUrl;
String? baseUrl;
String defaultContentType = 'application/json; charset=utf-8';
... ... @@ -28,7 +28,7 @@ class GetHttpClient {
int maxRedirects;
int maxAuthRetries;
Decoder defaultDecoder;
Decoder? defaultDecoder;
Duration timeout;
... ... @@ -46,7 +46,7 @@ class GetHttpClient {
this.maxAuthRetries = 1,
bool allowAutoSignedCert = false,
this.baseUrl,
List<TrustedCertificate> trustedCertificates,
List<TrustedCertificate>? trustedCertificates,
}) : _httpClient = HttpRequestImpl(
allowAutoSignedCert: allowAutoSignedCert,
trustedCertificates: trustedCertificates,
... ... @@ -73,11 +73,11 @@ class GetHttpClient {
_modifier.removeResponseModifier<T>(interceptor);
}
Uri _createUri(String url, Map<String, dynamic> query) {
Uri _createUri(String? url, Map<String, dynamic>? query) {
if (baseUrl != null) {
url = baseUrl + url;
url = baseUrl! + url!;
}
final uri = Uri.parse(url);
final uri = Uri.parse(url!);
if (query != null) {
return uri.replace(queryParameters: query);
}
... ... @@ -85,16 +85,16 @@ class GetHttpClient {
}
Future<Request<T>> _requestWithBody<T>(
String url,
String contentType,
String? url,
String? contentType,
dynamic body,
String method,
Map<String, dynamic> query,
Decoder<T> decoder,
Progress uploadProgress,
Map<String, dynamic>? query,
Decoder<T>? decoder,
Progress? uploadProgress,
) async {
List<int> bodyBytes;
BodyBytesStream bodyStream;
List<int>? bodyBytes;
BodyBytesStream? bodyStream;
final headers = <String, String>{};
headers['user-agent'] = userAgent;
... ... @@ -139,7 +139,7 @@ class GetHttpClient {
url: uri,
headers: headers,
bodyBytes: bodyStream,
contentLength: bodyBytes.length,
contentLength: bodyBytes!.length,
followRedirects: followRedirects,
maxRedirects: maxRedirects,
decoder: decoder,
... ... @@ -148,7 +148,7 @@ class GetHttpClient {
BodyBytesStream _trackProgress(
List<int> bodyBytes,
Progress uploadProgress,
Progress? uploadProgress,
) {
var total = 0;
var length = bodyBytes.length;
... ... @@ -169,7 +169,7 @@ class GetHttpClient {
void _setSimpleHeaders(
Map<String, String> headers,
String contentType,
String? contentType,
) {
headers['content-type'] = contentType ?? defaultContentType;
headers['user-agent'] = userAgent;
... ... @@ -179,7 +179,7 @@ class GetHttpClient {
HandlerExecute<T> handler, {
bool authenticate = false,
int requestNumber = 1,
Map<String, String> headers,
Map<String, String>? headers,
}) async {
try {
var request = await handler();
... ... @@ -188,7 +188,7 @@ class GetHttpClient {
request.headers[key] = value;
});
if (authenticate) await _modifier.authenticator(request);
if (authenticate) await _modifier.authenticator!(request);
await _modifier.modifyRequest(request);
var response = await _httpClient.send<T>(request);
... ... @@ -238,9 +238,9 @@ class GetHttpClient {
Future<Request<T>> _get<T>(
String url,
String contentType,
Map<String, dynamic> query,
Decoder<T> decoder,
String? contentType,
Map<String, dynamic>? query,
Decoder<T>? decoder,
) {
final headers = <String, String>{};
_setSimpleHeaders(headers, contentType);
... ... @@ -250,18 +250,18 @@ class GetHttpClient {
method: 'get',
url: uri,
headers: headers,
decoder: decoder ?? (defaultDecoder as Decoder<T>),
decoder: decoder ?? (defaultDecoder as Decoder<T>?),
));
}
Future<Request<T>> _request<T>(
String url,
String? url,
String method, {
String contentType,
@required dynamic body,
@required Map<String, dynamic> query,
Decoder<T> decoder,
@required Progress uploadProgress,
String? contentType,
required dynamic body,
required Map<String, dynamic>? query,
Decoder<T>? decoder,
required Progress? uploadProgress,
}) {
return _requestWithBody<T>(
url,
... ... @@ -269,16 +269,16 @@ class GetHttpClient {
body,
method,
query,
decoder ?? (defaultDecoder as Decoder<T>),
decoder ?? (defaultDecoder as Decoder<T>?),
uploadProgress,
);
}
Request<T> _delete<T>(
String url,
String contentType,
Map<String, dynamic> query,
Decoder<T> decoder,
String? contentType,
Map<String, dynamic>? query,
Decoder<T>? decoder,
) {
final headers = <String, String>{};
_setSimpleHeaders(headers, contentType);
... ... @@ -288,18 +288,18 @@ class GetHttpClient {
method: 'delete',
url: uri,
headers: headers,
decoder: decoder ?? (defaultDecoder as Decoder<T>),
decoder: decoder ?? (defaultDecoder as Decoder<T>?),
);
}
Future<Response<T>> patch<T>(
String url, {
dynamic body,
String contentType,
Map<String, String> headers,
Map<String, dynamic> query,
Decoder<T> decoder,
Progress uploadProgress,
String? contentType,
Map<String, String>? headers,
Map<String, dynamic>? query,
Decoder<T>? decoder,
Progress? uploadProgress,
// List<MultipartFile> files,
}) async {
try {
... ... @@ -327,13 +327,13 @@ class GetHttpClient {
}
Future<Response<T>> post<T>(
String url, {
String? url, {
dynamic body,
String contentType,
Map<String, String> headers,
Map<String, dynamic> query,
Decoder<T> decoder,
Progress uploadProgress,
String? contentType,
Map<String, String>? headers,
Map<String, dynamic>? query,
Decoder<T>? decoder,
Progress? uploadProgress,
// List<MultipartFile> files,
}) async {
try {
... ... @@ -364,11 +364,11 @@ class GetHttpClient {
String url,
String method, {
dynamic body,
String contentType,
Map<String, String> headers,
Map<String, dynamic> query,
Decoder<T> decoder,
Progress uploadProgress,
String? contentType,
Map<String, String>? headers,
Map<String, dynamic>? query,
Decoder<T>? decoder,
Progress? uploadProgress,
}) async {
try {
var response = await _performRequest<T>(
... ... @@ -397,11 +397,11 @@ class GetHttpClient {
Future<Response<T>> put<T>(
String url, {
dynamic body,
String contentType,
Map<String, String> headers,
Map<String, dynamic> query,
Decoder<T> decoder,
Progress uploadProgress,
String? contentType,
Map<String, String>? headers,
Map<String, dynamic>? query,
Decoder<T>? decoder,
Progress? uploadProgress,
}) async {
try {
var response = await _performRequest<T>(
... ... @@ -429,10 +429,10 @@ class GetHttpClient {
Future<Response<T>> get<T>(
String url, {
Map<String, String> headers,
String contentType,
Map<String, dynamic> query,
Decoder<T> decoder,
Map<String, String>? headers,
String? contentType,
Map<String, dynamic>? query,
Decoder<T>? decoder,
}) async {
try {
var response = await _performRequest<T>(
... ... @@ -513,10 +513,10 @@ class GetHttpClient {
Future<Response<T>> delete<T>(
String url, {
Map<String, String> headers,
String contentType,
Map<String, dynamic> query,
Decoder<T> decoder,
Map<String, String>? headers,
String? contentType,
Map<String, dynamic>? query,
Decoder<T>? decoder,
}) async {
try {
var response = await _performRequest<T>(
... ...
... ... @@ -13,7 +13,7 @@ import '../utils/body_decoder.dart';
class HttpRequestImpl implements HttpRequestBase {
HttpRequestImpl({
bool allowAutoSignedCert = true,
List<TrustedCertificate> trustedCertificates,
List<TrustedCertificate>? trustedCertificates,
});
/// The currently active XHRs.
... ... @@ -41,16 +41,16 @@ class HttpRequestImpl implements HttpRequestBase {
var completer = Completer<Response<T>>();
xhr.onLoad.first.then((_) {
var blob = xhr.response as html.Blob ?? html.Blob([]);
var blob = xhr.response as html.Blob? ?? html.Blob([]);
var reader = html.FileReader();
reader.onLoad.first.then((_) async {
var bodyBytes = BodyBytesStream.fromBytes(reader.result as Uint8List);
var bodyBytes = BodyBytesStream.fromBytes(reader.result as Uint8List?);
final stringBody =
await bodyBytesToString(bodyBytes, xhr.responseHeaders);
String contentType;
String? contentType;
if (xhr.responseHeaders.containsKey('content-type')) {
contentType = xhr.responseHeaders['content-type'];
... ...
... ... @@ -10,33 +10,33 @@ import '../utils/body_decoder.dart';
/// A `dart:io` implementation of `HttpRequestBase`.
class HttpRequestImpl extends HttpRequestBase {
io.HttpClient _httpClient;
io.SecurityContext _securityContext;
io.HttpClient? _httpClient;
io.SecurityContext? _securityContext;
HttpRequestImpl({
bool allowAutoSignedCert = true,
List<TrustedCertificate> trustedCertificates,
List<TrustedCertificate>? trustedCertificates,
}) {
_httpClient = io.HttpClient();
if (trustedCertificates != null) {
_securityContext = io.SecurityContext();
for (final trustedCertificate in trustedCertificates) {
_securityContext
_securityContext!
.setTrustedCertificatesBytes(List.from(trustedCertificate.bytes));
}
}
_httpClient = io.HttpClient(context: _securityContext);
_httpClient.badCertificateCallback = (_, __, ___) => allowAutoSignedCert;
_httpClient!.badCertificateCallback = (_, __, ___) => allowAutoSignedCert;
}
@override
Future<Response<T>> send<T>(Request<T> request) async {
var stream = request.bodyBytes.asBroadcastStream();
Stream<List<int>?> stream = request.bodyBytes.asBroadcastStream();
//var stream = BodyBytesStream.fromBytes(requestBody ?? const []);
try {
var ioRequest = (await _httpClient.openUrl(request.method, request.url))
var ioRequest = (await _httpClient!.openUrl(request.method, request.url))
..followRedirects = request.followRedirects
..persistentConnection = request.persistentConnection
..maxRedirects = request.maxRedirects
... ... @@ -77,7 +77,7 @@ class HttpRequestImpl extends HttpRequestBase {
@override
void close() {
if (_httpClient != null) {
_httpClient.close(force: true);
_httpClient!.close(force: true);
_httpClient = null;
}
}
... ...
... ... @@ -20,10 +20,10 @@ class MockClient extends HttpRequestBase {
var response = await _handler(request);
final stringBody = await bodyBytesToString(bodyBytes, response.headers);
final stringBody = await bodyBytesToString(bodyBytes, response.headers!);
var mimeType = response.headers.containsKey('content-type')
? response.headers['content-type']
var mimeType = response.headers!.containsKey('content-type')
? response.headers!['content-type']
: '';
final body = bodyDecoded<T>(
... ...
... ... @@ -6,7 +6,7 @@ import '../interface/request_base.dart';
class HttpRequestImpl extends HttpRequestBase {
HttpRequestImpl({
bool allowAutoSignedCert = true,
List<TrustedCertificate> trustedCertificates,
List<TrustedCertificate>? trustedCertificates,
});
@override
void close() {}
... ...
... ... @@ -4,8 +4,8 @@ import '../../../../../get_core/get_core.dart';
import '../../request/request.dart';
T bodyDecoded<T>(Request<T> request, String stringBody, String mimeType) {
T body;
T? bodyDecoded<T>(Request<T> request, String stringBody, String? mimeType) {
T? body;
var bodyToDecode;
if (mimeType != null && mimeType.contains('application/json')) {
... ... @@ -23,9 +23,9 @@ T bodyDecoded<T>(Request<T> request, String stringBody, String mimeType) {
if (stringBody == '') {
body = null;
} else if (request.decoder == null) {
body = bodyToDecode as T;
body = bodyToDecode as T?;
} else {
body = request.decoder(bodyToDecode);
body = request.decoder!(bodyToDecode);
}
} on Exception catch (_) {
body = stringBody as T;
... ...
... ... @@ -3,17 +3,17 @@ import 'dart:async';
import '../request/request.dart';
import '../response/response.dart';
typedef RequestModifier<T> = FutureOr<Request<T>> Function(Request<T> request);
typedef RequestModifier<T> = FutureOr<Request<T>> Function(Request<T?> request);
typedef ResponseModifier<T> = FutureOr Function(
Request<T> request, Response<T> response);
Request<T?> request, Response<T?> response);
typedef HandlerExecute<T> = Future<Request<T>> Function();
class GetModifier<T> {
final _requestModifiers = <RequestModifier>[];
final _responseModifiers = <ResponseModifier>[];
RequestModifier authenticator;
RequestModifier? authenticator;
void addRequestModifier<T>(RequestModifier<T> interceptor) {
_requestModifiers.add(interceptor as RequestModifier);
... ...
... ... @@ -83,7 +83,7 @@ class FormData {
_maxBoundaryLength +
'\r\n'.length +
utf8.encode(_fileHeader(file)).length +
file.value.length +
file.value.length! +
'\r\n'.length;
}
... ... @@ -109,7 +109,7 @@ class FormData {
for (final file in files) {
yield separator;
yield utf8.encode(_fileHeader(file));
yield* file.value.stream;
yield* file.value.stream! as Stream<List<int>>;
yield line;
}
yield close;
... ...
... ... @@ -9,7 +9,7 @@ import '../request/request.dart';
class MultipartFile {
MultipartFile(
dynamic data, {
@required this.filename,
required this.filename,
this.contentType = 'application/octet-stream',
}) : _bytes = fileToBytes(data) {
_length = _bytes.length;
... ... @@ -21,13 +21,13 @@ class MultipartFile {
final String contentType;
/// This stream will emit the file content of File.
BodyBytesStream _stream;
BodyBytesStream? _stream;
int _length;
int? _length;
BodyBytesStream get stream => _stream;
BodyBytesStream? get stream => _stream;
int get length => _length;
int? get length => _length;
final String filename;
}
... ...
... ... @@ -2,8 +2,6 @@ import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
import 'package:flutter/foundation.dart';
import '../http.dart';
import '../multipart/form_data.dart';
... ... @@ -14,13 +12,13 @@ class Request<T> {
/// The [Uri] from request
final Uri url;
final Decoder<T> decoder;
final Decoder<T>? decoder;
/// The Http Method from this [Request]
/// ex: `GET`,`POST`,`PUT`,`DELETE`
final String method;
final int contentLength;
final int? contentLength;
/// The BodyBytesStream of body from this [Request]
final BodyBytesStream bodyBytes;
... ... @@ -33,45 +31,41 @@ class Request<T> {
final bool persistentConnection;
final FormData files;
final FormData? files;
const Request._({
@required this.method,
@required this.bodyBytes,
@required this.url,
@required this.headers,
@required this.contentLength,
@required this.followRedirects,
@required this.maxRedirects,
@required this.files,
@required this.persistentConnection,
@required this.decoder,
required this.method,
required this.bodyBytes,
required this.url,
required this.headers,
required this.contentLength,
required this.followRedirects,
required this.maxRedirects,
required this.files,
required this.persistentConnection,
required this.decoder,
});
factory Request({
@required Uri url,
@required String method,
@required Map<String, String> headers,
BodyBytesStream bodyBytes,
required Uri url,
required String method,
required Map<String, String> headers,
BodyBytesStream? bodyBytes,
bool followRedirects = true,
int maxRedirects = 4,
int contentLength,
FormData files,
int? contentLength,
FormData? files,
bool persistentConnection = true,
Decoder<T> decoder,
Decoder<T>? decoder,
}) {
assert(url != null);
assert(method != null);
assert(followRedirects != null);
if (followRedirects) {
assert(maxRedirects != null);
assert(maxRedirects > 0);
}
return Request._(
url: url,
method: method,
bodyBytes: bodyBytes ??= BodyBytesStream.fromBytes(const []),
headers: Map.from(headers ??= <String, String>{}),
headers: Map.from(headers),
followRedirects: followRedirects,
maxRedirects: maxRedirects,
contentLength: contentLength,
... ... @@ -82,10 +76,10 @@ class Request<T> {
}
}
class BodyBytesStream extends StreamView<List<int>> {
BodyBytesStream(Stream<List<int>> stream) : super(stream);
class BodyBytesStream extends StreamView<List<int>?> {
BodyBytesStream(Stream<List<int>?> stream) : super(stream);
factory BodyBytesStream.fromBytes(List<int> bytes) =>
factory BodyBytesStream.fromBytes(List<int>? bytes) =>
BodyBytesStream(Stream.fromIterable([bytes]));
Future<Uint8List> toBytes() {
... ... @@ -95,7 +89,7 @@ class BodyBytesStream extends StreamView<List<int>> {
Uint8List.fromList(bytes),
),
);
listen(sink.add,
listen((val) => sink.add(val!),
onError: completer.completeError,
onDone: sink.close,
cancelOnError: true);
... ... @@ -103,5 +97,5 @@ class BodyBytesStream extends StreamView<List<int>> {
}
Future<String> bytesToString([Encoding encoding = utf8]) =>
encoding.decodeStream(this);
encoding.decodeStream(this as Stream<List<int>>);
}
... ...
... ... @@ -5,8 +5,8 @@ import '../request/request.dart';
import '../status/http_status.dart';
class GraphQLResponse<T> extends Response<T> {
final List<GraphQLError> graphQLErrors;
GraphQLResponse({T body, this.graphQLErrors}) : super(body: body);
final List<GraphQLError>? graphQLErrors;
GraphQLResponse({T? body, this.graphQLErrors}) : super(body: body);
}
class Response<T> {
... ... @@ -21,16 +21,16 @@ class Response<T> {
});
/// The Http [Request] linked with this [Response].
final Request request;
final Request? request;
/// The response headers.
final Map<String, String> headers;
final Map<String, String>? headers;
/// The status code returned by the server.
final int statusCode;
final int? statusCode;
/// Human-readable context for [statusCode].
final String statusText;
final String? statusText;
/// [HttpStatus] from [Response]. `status.connectionError` is true
/// when statusCode is null. `status.isUnauthorized` is true when
... ... @@ -49,15 +49,15 @@ class Response<T> {
bool get unauthorized => status.isUnauthorized;
/// The response body as a Stream of Bytes.
final BodyBytesStream bodyBytes;
final BodyBytesStream? bodyBytes;
/// The response body as a Stream of Bytes.
final String bodyString;
final String? bodyString;
/// The decoded body of this [Response]. You can access the
/// body parameters as Map
/// Ex: body['title'];
final T body;
final T? body;
}
Future<String> bodyBytesToString(
... ... @@ -70,13 +70,13 @@ Future<String> bodyBytesToString(
/// Defaults to [latin1] if the headers don't specify a charset or if that
/// charset is unknown.
Encoding _encodingForHeaders(Map<String, String> headers) =>
_encodingForCharset(_contentTypeForHeaders(headers).parameters['charset']);
_encodingForCharset(_contentTypeForHeaders(headers).parameters!['charset']);
/// Returns the [Encoding] that corresponds to [charset].
///
/// Returns [fallback] if [charset] is null or if no [Encoding] was found that
/// corresponds to [charset].
Encoding _encodingForCharset(String charset, [Encoding fallback = latin1]) {
Encoding _encodingForCharset(String? charset, [Encoding fallback = latin1]) {
if (charset == null) return fallback;
return Encoding.getByName(charset) ?? fallback;
}
... ... @@ -92,10 +92,10 @@ HeaderValue _contentTypeForHeaders(Map<String, String> headers) {
class HeaderValue {
String _value;
Map<String, String> _parameters;
Map<String, String> _unmodifiableParameters;
Map<String, String?>? _parameters;
Map<String, String?>? _unmodifiableParameters;
HeaderValue([this._value = '', Map<String, String> parameters]) {
HeaderValue([this._value = '', Map<String, String>? parameters]) {
if (parameters != null) {
_parameters = HashMap<String, String>.from(parameters);
}
... ... @@ -103,7 +103,7 @@ class HeaderValue {
static HeaderValue parse(String value,
{String parameterSeparator = ';',
String valueSeparator,
String? valueSeparator,
bool preserveBackslash = false}) {
var result = HeaderValue();
result._parse(value, parameterSeparator, valueSeparator, preserveBackslash);
... ... @@ -116,9 +116,9 @@ class HeaderValue {
_parameters ??= HashMap<String, String>();
}
Map<String, String> get parameters {
Map<String, String?>? get parameters {
_ensureParameters();
_unmodifiableParameters ??= UnmodifiableMapView(_parameters);
_unmodifiableParameters ??= UnmodifiableMapView(_parameters!);
return _unmodifiableParameters;
}
... ... @@ -126,15 +126,15 @@ class HeaderValue {
String toString() {
var stringBuffer = StringBuffer();
stringBuffer.write(_value);
if (parameters != null && parameters.isNotEmpty) {
_parameters.forEach((name, value) {
if (parameters != null && parameters!.isNotEmpty) {
_parameters!.forEach((name, value) {
stringBuffer..write('; ')..write(name)..write('=')..write(value);
});
}
return stringBuffer.toString();
}
void _parse(String value, String parameterSeparator, String valueSeparator,
void _parse(String value, String parameterSeparator, String? valueSeparator,
bool preserveBackslash) {
var index = 0;
... ... @@ -173,7 +173,7 @@ class HeaderValue {
}
void parseParameters() {
var parameters = HashMap<String, String>();
var parameters = HashMap<String, String?>();
_parameters = UnmodifiableMapView(parameters);
String parseParameterName() {
... ... @@ -191,7 +191,7 @@ class HeaderValue {
return value.substring(start, index).toLowerCase();
}
String parseParameterValue() {
String? parseParameterValue() {
if (!done() && value[index] == '\"') {
var stringBuffer = StringBuffer();
index++;
... ...
class HttpStatus {
HttpStatus(this.code);
final int code;
final int? code;
static const int continue_ = 100;
static const int switchingProtocols = 101;
... ... @@ -83,7 +83,7 @@ class HttpStatus {
between(internalServerError, networkConnectTimeoutError);
bool between(int begin, int end) {
return !connectionError && code >= begin && code <= end;
return !connectionError && code! >= begin && code! <= end;
}
bool get isOk => between(200, 299);
... ...
... ... @@ -53,7 +53,7 @@ String validateField(String field) {
}
BodyBytesStream toBodyBytesStream(Stream<List<int>> stream) {
if (stream is BodyBytesStream) return stream;
if (stream is BodyBytesStream) return stream as BodyBytesStream;
return BodyBytesStream(stream);
}
... ...
... ... @@ -3,7 +3,7 @@ import 'src/sockets_stub.dart'
if (dart.library.io) 'src/sockets_io.dart';
class GetSocket extends BaseWebSocket {
GetSocket(String url,
GetSocket(String? url,
{Duration ping = const Duration(seconds: 5), bool allowSelfSigned = true})
: super(url, ping: ping, allowSelfSigned: allowSelfSigned);
}
... ...
import 'dart:convert';
class Close {
final String message;
final int reason;
final String? message;
final int? reason;
Close(this.message, this.reason);
... ... @@ -19,31 +19,31 @@ typedef CloseSocket = void Function(Close);
typedef MessageSocket = void Function(dynamic val);
class SocketNotifier {
var _onMessages = <MessageSocket>[];
var _onEvents = <String, MessageSocket>{};
var _onCloses = <CloseSocket>[];
var _onErrors = <CloseSocket>[];
List<void Function(dynamic)>? _onMessages = <MessageSocket>[];
Map<String, void Function(dynamic)>? _onEvents = <String, MessageSocket>{};
List<void Function(Close)>? _onCloses = <CloseSocket>[];
List<void Function(Close)>? _onErrors = <CloseSocket>[];
OpenSocket open;
late OpenSocket open;
void addMessages(MessageSocket socket) {
_onMessages.add((socket));
_onMessages!.add((socket));
}
void addEvents(String event, MessageSocket socket) {
_onEvents[event] = socket;
_onEvents![event] = socket;
}
void addCloses(CloseSocket socket) {
_onCloses.add(socket);
_onCloses!.add(socket);
}
void addErrors(CloseSocket socket) {
_onErrors.add((socket));
_onErrors!.add((socket));
}
void notifyData(dynamic data) {
for (var item in _onMessages) {
for (var item in _onMessages!) {
item(data);
}
if (data is String) {
... ... @@ -52,14 +52,14 @@ class SocketNotifier {
}
void notifyClose(Close err) {
for (var item in _onCloses) {
for (var item in _onCloses!) {
item(err);
}
}
void notifyError(Close err) {
// rooms.removeWhere((key, value) => value.contains(_ws));
for (var item in _onErrors) {
for (var item in _onErrors!) {
item(err);
}
}
... ... @@ -69,8 +69,8 @@ class SocketNotifier {
var msg = jsonDecode(message);
final event = msg['type'];
final data = msg['data'];
if (_onEvents.containsKey(event)) {
_onEvents[event](data);
if (_onEvents!.containsKey(event)) {
_onEvents![event]!(data);
}
} on Exception catch (_) {
return;
... ...
... ... @@ -15,8 +15,8 @@ enum ConnectionStatus {
class BaseWebSocket {
String url;
WebSocket socket;
SocketNotifier socketNotifier = SocketNotifier();
WebSocket? socket;
SocketNotifier? socketNotifier = SocketNotifier();
Duration ping;
bool isDisposed = false;
bool allowSelfSigned;
... ... @@ -30,39 +30,39 @@ class BaseWebSocket {
? url.replaceAll('https:', 'wss:')
: url.replaceAll('http:', 'ws:');
}
ConnectionStatus connectionStatus;
Timer _t;
ConnectionStatus? connectionStatus;
Timer? _t;
void connect() {
try {
connectionStatus = ConnectionStatus.connecting;
socket = WebSocket(url);
socket.onOpen.listen((e) {
socket!.onOpen.listen((e) {
socketNotifier?.open();
_t = Timer?.periodic(ping, (t) {
socket.send('');
socket!.send('');
});
connectionStatus = ConnectionStatus.connected;
});
socket.onMessage.listen((event) {
socketNotifier.notifyData(event.data);
socket!.onMessage.listen((event) {
socketNotifier!.notifyData(event.data);
});
socket.onClose.listen((e) {
socket!.onClose.listen((e) {
_t?.cancel();
connectionStatus = ConnectionStatus.closed;
socketNotifier.notifyClose(Close(e.reason, e.code));
socketNotifier!.notifyClose(Close(e.reason, e.code));
});
socket.onError.listen((event) {
socket!.onError.listen((event) {
_t?.cancel();
socketNotifier.notifyError(Close(event.toString(), 0));
socketNotifier!.notifyError(Close(event.toString(), 0));
connectionStatus = ConnectionStatus.closed;
});
} on Exception catch (e) {
_t?.cancel();
socketNotifier.notifyError(Close(e.toString(), 500));
socketNotifier!.notifyError(Close(e.toString(), 500));
connectionStatus = ConnectionStatus.closed;
// close(500, e.toString());
}
... ... @@ -70,35 +70,35 @@ class BaseWebSocket {
// ignore: use_setters_to_change_properties
void onOpen(OpenSocket fn) {
socketNotifier.open = fn;
socketNotifier!.open = fn;
}
void onClose(CloseSocket fn) {
socketNotifier.addCloses(fn);
socketNotifier!.addCloses(fn);
}
void onError(CloseSocket fn) {
socketNotifier.addErrors(fn);
socketNotifier!.addErrors(fn);
}
void onMessage(MessageSocket fn) {
socketNotifier.addMessages(fn);
socketNotifier!.addMessages(fn);
}
void on(String event, MessageSocket message) {
socketNotifier.addEvents(event, message);
socketNotifier!.addEvents(event, message);
}
void close([int status, String reason]) {
if (socket != null) socket.close(status, reason);
void close([int? status, String? reason]) {
if (socket != null) socket!.close(status, reason);
}
void send(dynamic data) {
if (connectionStatus == ConnectionStatus.closed) {
connect();
}
if (socket != null && socket.readyState == WebSocket.OPEN) {
socket.send(data);
if (socket != null && socket!.readyState == WebSocket.OPEN) {
socket!.send(data);
} else {
Get.log('WebSocket not connected, message $data not sent');
}
... ... @@ -109,7 +109,7 @@ class BaseWebSocket {
}
void dispose() {
socketNotifier.dispose();
socketNotifier!.dispose();
socketNotifier = null;
isDisposed = true;
}
... ...
... ... @@ -15,8 +15,8 @@ enum ConnectionStatus {
class BaseWebSocket {
String url;
WebSocket socket;
SocketNotifier socketNotifier = SocketNotifier();
WebSocket? socket;
SocketNotifier? socketNotifier = SocketNotifier();
bool isDisposed = false;
BaseWebSocket(
this.url, {
... ... @@ -26,7 +26,7 @@ class BaseWebSocket {
Duration ping;
bool allowSelfSigned;
ConnectionStatus connectionStatus;
ConnectionStatus? connectionStatus;
Future connect() async {
if (isDisposed) {
... ... @@ -38,51 +38,51 @@ class BaseWebSocket {
? await _connectForSelfSignedCert(url)
: await WebSocket.connect(url);
socket.pingInterval = ping;
socket!.pingInterval = ping;
socketNotifier?.open();
connectionStatus = ConnectionStatus.connected;
socket.listen((data) {
socketNotifier.notifyData(data);
socket!.listen((data) {
socketNotifier!.notifyData(data);
}, onError: (err) {
socketNotifier.notifyError(Close(err.toString(), 1005));
socketNotifier!.notifyError(Close(err.toString(), 1005));
}, onDone: () {
connectionStatus = ConnectionStatus.closed;
socketNotifier
.notifyClose(Close('Connection Closed', socket.closeCode));
socketNotifier!
.notifyClose(Close('Connection Closed', socket!.closeCode));
}, cancelOnError: true);
return;
} on SocketException catch (e) {
connectionStatus = ConnectionStatus.closed;
socketNotifier.notifyError(Close(e.osError.message, e.osError.errorCode));
socketNotifier!.notifyError(Close(e.osError!.message, e.osError!.errorCode));
return;
}
}
// ignore: use_setters_to_change_properties
void onOpen(OpenSocket fn) {
socketNotifier.open = fn;
socketNotifier!.open = fn;
}
void onClose(CloseSocket fn) {
socketNotifier.addCloses(fn);
socketNotifier!.addCloses(fn);
}
void onError(CloseSocket fn) {
socketNotifier.addErrors(fn);
socketNotifier!.addErrors(fn);
}
void onMessage(MessageSocket fn) {
socketNotifier.addMessages(fn);
socketNotifier!.addMessages(fn);
}
void on(String event, MessageSocket message) {
socketNotifier.addEvents(event, message);
socketNotifier!.addEvents(event, message);
}
void close([int status, String reason]) {
void close([int? status, String? reason]) {
if (socket != null) {
socket.close(status, reason);
socket!.close(status, reason);
}
}
... ... @@ -92,12 +92,12 @@ class BaseWebSocket {
}
if (socket != null) {
socket.add(data);
socket!.add(data);
}
}
void dispose() {
socketNotifier.dispose();
socketNotifier!.dispose();
socketNotifier = null;
isDisposed = true;
}
... ...
import './socket_notifier.dart';
class BaseWebSocket {
String url;
String? url;
Duration ping;
bool allowSelfSigned;
BaseWebSocket(
... ... @@ -36,7 +36,7 @@ class BaseWebSocket {
throw 'To use sockets you need dart:io or dart:html';
}
void close([int status, String reason]) {
void close([int? status, String? reason]) {
throw 'To use sockets you need dart:io or dart:html';
}
... ...
... ... @@ -5,7 +5,7 @@ import 'smart_management.dart';
/// class through extensions
abstract class GetInterface {
SmartManagement smartManagement = SmartManagement.full;
String reference;
String? reference;
bool isLogEnable = true;
LogWriterCallback log = defaultLogWriterCallback;
}
... ...
... ... @@ -2,9 +2,9 @@ import 'dart:developer' as developer;
import 'get_main.dart';
///Voidcallback from logs
typedef LogWriterCallback = void Function(String text, {bool isError});
typedef LogWriterCallback = void Function(String text, {bool? isError});
/// default logger from GetX
void defaultLogWriterCallback(String value, {bool isError = false}) {
if (isError || Get.isLogEnable) developer.log(value, name: 'GETX');
void defaultLogWriterCallback(String value, {bool? isError = false}) {
if (isError! || Get.isLogEnable) developer.log(value, name: 'GETX');
}
... ...
... ... @@ -42,7 +42,7 @@ class BindingsBuilder<T> extends Bindings {
/// ),
/// ```
factory BindingsBuilder.put(InstanceBuilderCallback<T> builder,
{String tag, bool permanent = false}) {
{String? tag, bool permanent = false}) {
return BindingsBuilder(
() => GetInstance().put<T>(builder(), tag: tag, permanent: permanent));
}
... ...
... ... @@ -28,7 +28,7 @@ extension Inst on GetInterface {
/// Subsequent calls to [Get.lazyPut()] with the same parameters
/// (<[S]> and optionally [tag] will **not** override the original).
void lazyPut<S>(InstanceBuilderCallback<S> builder,
{String tag, bool fenix = false}) {
{String? tag, bool fenix = false}) {
GetInstance().lazyPut<S>(builder, tag: tag, fenix: fenix);
}
... ... @@ -39,8 +39,8 @@ extension Inst on GetInterface {
/// async version of [Get.put()].
/// Awaits for the resolution of the Future from [builder()] parameter and
/// stores the Instance returned.
Future<S> putAsync<S>(AsyncInstanceBuilderCallback<S> builder,
{String tag, bool permanent = false}) async =>
Future<S?> putAsync<S>(AsyncInstanceBuilderCallback<S> builder,
{String? tag, bool permanent = false}) async =>
GetInstance().putAsync<S>(builder, tag: tag, permanent: permanent);
/// Creates a new Class Instance [S] from the builder callback[S].
... ... @@ -61,13 +61,13 @@ extension Inst on GetInterface {
/// Repl b = find();
/// print(a==b); (false)```
void create<S>(InstanceBuilderCallback<S> builder,
{String tag, bool permanent = true}) =>
{String? tag, bool permanent = true}) =>
GetInstance().create<S>(builder, tag: tag, permanent: permanent);
/// Finds a Instance of the required Class <[S]>(or [tag])
/// In the case of using [Get.create()], it will generate an Instance
/// each time you call [Get.find()].
S find<S>({String tag}) => GetInstance().find<S>(tag: tag);
S? find<S>({String? tag}) => GetInstance().find<S>(tag: tag);
/// Injects an [Instance<S>] in memory.
///
... ... @@ -83,10 +83,10 @@ extension Inst on GetInterface {
/// rules. Although, can be removed by [GetInstance.reset()]
/// and [Get.delete()]
/// - [builder] If defined, the [dependency] must be returned from here
S put<S>(S dependency,
{String tag,
S? put<S>(S dependency,
{String? tag,
bool permanent = false,
InstanceBuilderCallback<S> builder}) =>
InstanceBuilderCallback<S>? builder}) =>
GetInstance().put<S>(dependency, tag: tag, permanent: permanent);
/// Clears all registered instances (and/or tags).
... ... @@ -104,15 +104,15 @@ extension Inst on GetInterface {
///
/// - [tag] Optional "tag" used to register the Instance
/// - [force] Will delete an Instance even if marked as [permanent].
Future<bool> delete<S>({String tag, bool force = false}) async =>
Future<bool> delete<S>({String? tag, bool force = false}) async =>
GetInstance().delete<S>(tag: tag, force: force);
/// Checks if a Class Instance<[S]> (or [tag]) is registered in memory.
/// - [tag] optional, if you use a [tag] to register the Instance.
bool isRegistered<S>({String tag}) => GetInstance().isRegistered<S>(tag: tag);
bool isRegistered<S>({String? tag}) => GetInstance().isRegistered<S>(tag: tag);
/// Checks if an Instance<[S]> (or [tag]) returned from a factory builder
/// [Get.lazyPut()], is registered in memory.
/// - [tag] optional, if you use a [tag] to register the Instance.
bool isPrepared<S>({String tag}) => GetInstance().isPrepared<S>(tag: tag);
bool isPrepared<S>({String? tag}) => GetInstance().isPrepared<S>(tag: tag);
}
... ...
... ... @@ -8,18 +8,18 @@ import '../../get_core/get_core.dart';
import 'lifecycle.dart';
class InstanceInfo {
final bool isPermanent;
final bool isSingleton;
bool get isCreate => !isSingleton;
final bool? isPermanent;
final bool? isSingleton;
bool get isCreate => !isSingleton!;
final bool isRegistered;
final bool isPrepared;
final bool isInit;
final bool? isInit;
const InstanceInfo({
@required this.isPermanent,
@required this.isSingleton,
@required this.isRegistered,
@required this.isPrepared,
@required this.isInit,
required this.isPermanent,
required this.isSingleton,
required this.isRegistered,
required this.isPrepared,
required this.isInit,
});
}
... ... @@ -28,9 +28,9 @@ class GetInstance {
const GetInstance._();
static GetInstance _getInstance;
static GetInstance? _getInstance;
T call<T>() => find<T>();
T? call<T>() => find<T>();
/// Holds references to every registered Instance when using
/// [Get.put()]
... ... @@ -42,13 +42,13 @@ class GetInstance {
/// Holds a reference to [Get.reference] when the Instance was
/// created to manage the memory.
static final Map<String, String> _routesKey = {};
static final Map<String, String?> _routesKey = {};
/// Stores the onClose() references of instances created with [Get.create()]
/// using the [Get.reference].
/// Experimental feature to keep the lifecycle and memory management with
/// non-singleton instances.
static final Map<String, HashSet<Function>> _routesByCreate = {};
static final Map<String?, HashSet<Function>> _routesByCreate = {};
void printInstanceStack() {
Get.log(_routesKey.toString());
... ... @@ -56,7 +56,7 @@ class GetInstance {
void injector<S>(
InjectorBuilderCallback<S> fn, {
String tag,
String? tag,
bool fenix = false,
// bool permanent = false,
}) {
... ... @@ -71,9 +71,9 @@ class GetInstance {
/// async version of [Get.put()].
/// Awaits for the resolution of the Future from [builder()] parameter and
/// stores the Instance returned.
Future<S> putAsync<S>(
Future<S?> putAsync<S>(
AsyncInstanceBuilderCallback<S> builder, {
String tag,
String? tag,
bool permanent = false,
}) async {
return put<S>(await builder(), tag: tag, permanent: permanent);
... ... @@ -89,11 +89,11 @@ class GetInstance {
/// the same Type<[S]>
/// - [permanent] keeps the Instance in memory, not following
/// [Get.smartManagement] rules.
S put<S>(
S? put<S>(
S dependency, {
String tag,
String? tag,
bool permanent = false,
@deprecated InstanceBuilderCallback<S> builder,
@deprecated InstanceBuilderCallback<S>? builder,
}) {
_insert(
isSingleton: true,
... ... @@ -127,8 +127,8 @@ class GetInstance {
/// (<[S]> and optionally [tag] will **not** override the original).
void lazyPut<S>(
InstanceBuilderCallback<S> builder, {
String tag,
bool fenix,
String? tag,
bool? fenix,
bool permanent = false,
}) {
_insert(
... ... @@ -158,7 +158,7 @@ class GetInstance {
/// print(a==b); (false)```
void create<S>(
InstanceBuilderCallback<S> builder, {
String tag,
String? tag,
bool permanent = true,
}) {
_insert(
... ... @@ -171,10 +171,10 @@ class GetInstance {
/// Injects the Instance [S] builder into the [_singleton] HashMap.
void _insert<S>({
bool isSingleton,
String name,
bool? isSingleton,
String? name,
bool permanent = false,
InstanceBuilderCallback<S> builder,
required InstanceBuilderCallback<S> builder,
bool fenix = false,
}) {
assert(builder != null);
... ... @@ -206,14 +206,14 @@ class GetInstance {
/// Removes [Get.create()] instances registered in [routeName].
if (_routesByCreate.containsKey(routeName)) {
for (final onClose in _routesByCreate[routeName]) {
for (final onClose in _routesByCreate[routeName]!) {
// assure the [DisposableInterface] instance holding a reference
// to [onClose()] wasn't disposed.
if (onClose != null) {
onClose();
}
}
_routesByCreate[routeName].clear();
_routesByCreate[routeName]!.clear();
_routesByCreate.remove(routeName);
}
... ... @@ -236,14 +236,14 @@ class GetInstance {
/// (not for Singletons access).
/// Returns the instance if not initialized, required for Get.create() to
/// work properly.
S _initDependencies<S>({String name}) {
S? _initDependencies<S>({String? name}) {
final key = _getKey(S, name);
final isInit = _singl[key].isInit;
S i;
final isInit = _singl[key]!.isInit;
S? i;
if (!isInit) {
i = _startController<S>(tag: name);
if (_singl[key].isSingleton) {
_singl[key].isInit = true;
if (_singl[key]!.isSingleton!) {
_singl[key]!.isInit = true;
if (Get.smartManagement != SmartManagement.onlyBuilder) {
_registerRouteInstance<S>(tag: name);
}
... ... @@ -254,11 +254,11 @@ class GetInstance {
/// Links a Class instance [S] (or [tag]) to the current route.
/// Requires usage of [GetMaterialApp].
void _registerRouteInstance<S>({String tag}) {
void _registerRouteInstance<S>({String? tag}) {
_routesKey.putIfAbsent(_getKey(S, tag), () => Get.reference);
}
InstanceInfo getInstanceInfo<S>({String tag}) {
InstanceInfo getInstanceInfo<S>({String? tag}) {
final build = _getDependency<S>(tag: tag);
return InstanceInfo(
... ... @@ -270,7 +270,7 @@ class GetInstance {
);
}
_InstanceBuilderFactory _getDependency<S>({String tag, String key}) {
_InstanceBuilderFactory? _getDependency<S>({String? tag, String? key}) {
final newKey = key ?? _getKey(S, tag);
if (!_singl.containsKey(newKey)) {
... ... @@ -282,9 +282,9 @@ class GetInstance {
}
/// Initializes the controller
S _startController<S>({String tag}) {
S? _startController<S>({String? tag}) {
final key = _getKey(S, tag);
final i = _singl[key].getDependency() as S;
final i = _singl[key]!.getDependency() as S?;
if (i is GetLifeCycleBase) {
if (i.onStart != null) {
i.onStart();
... ... @@ -294,19 +294,19 @@ class GetInstance {
Get.log('Instance "$S" with tag "$tag" has been initialized');
}
}
if (!_singl[key].isSingleton && i.onDelete != null) {
if (!_singl[key]!.isSingleton! && i.onDelete != null) {
_routesByCreate[Get.reference] ??= HashSet<Function>();
_routesByCreate[Get.reference].add(i.onDelete);
_routesByCreate[Get.reference]!.add(i.onDelete as Function);
}
}
return i;
}
S putOrFind<S>(InstanceBuilderCallback<S> dep, {String tag}) {
S? putOrFind<S>(InstanceBuilderCallback<S> dep, {String? tag}) {
final key = _getKey(S, tag);
if (_singl.containsKey(key)) {
return _singl[key].getDependency() as S;
return _singl[key]!.getDependency() as S?;
} else {
return GetInstance().put(dep(), tag: tag);
}
... ... @@ -317,7 +317,7 @@ class GetInstance {
/// it will create an instance each time you call [find].
/// If the registered type <[S]> (or [tag]) is a Controller,
/// it will initialize it's lifecycle.
S find<S>({String tag}) {
S? find<S>({String? tag}) {
final key = _getKey(S, tag);
if (isRegistered<S>(tag: tag)) {
if (_singl[key] == null) {
... ... @@ -332,7 +332,7 @@ class GetInstance {
/// `initDependencies`, so we have to return the instance from there
/// to make it compatible with `Get.create()`.
final i = _initDependencies<S>(name: tag);
return i ?? _singl[key].getDependency() as S;
return i ?? _singl[key]!.getDependency() as S?;
} else {
// ignore: lines_longer_than_80_chars
throw '"$S" not found. You need to call "Get.put($S())" or "Get.lazyPut(()=>$S())"';
... ... @@ -341,7 +341,7 @@ class GetInstance {
/// Generates the key based on [type] (and optionally a [name])
/// to register an Instance Builder in the hashmap.
String _getKey(Type type, String name) {
String _getKey(Type type, String? name) {
return name == null ? type.toString() : type.toString() + name;
}
... ... @@ -374,7 +374,7 @@ class GetInstance {
/// - [key] For internal usage, is the processed key used to register
/// the Instance. **don't use** it unless you know what you are doing.
/// - [force] Will delete an Instance even if marked as [permanent].
bool delete<S>({String tag, String key, bool force = false}) {
bool delete<S>({String? tag, String? key, bool force = false}) {
final newKey = key ?? _getKey(S, tag);
if (!_singl.containsKey(newKey)) {
... ... @@ -382,7 +382,7 @@ class GetInstance {
return false;
}
final builder = _singl[newKey];
final builder = _singl[newKey]!;
if (builder.permanent && !force) {
Get.log(
... ... @@ -430,7 +430,7 @@ class GetInstance {
});
}
void reload<S>({String tag, String key, bool force = false}) {
void reload<S>({String? tag, String? key, bool force = false}) {
final newKey = key ?? _getKey(S, tag);
final builder = _getDependency<S>(tag: tag, key: newKey);
... ... @@ -451,12 +451,12 @@ class GetInstance {
/// Check if a Class Instance<[S]> (or [tag]) is registered in memory.
/// - [tag] is optional, if you used a [tag] to register the Instance.
bool isRegistered<S>({String tag}) => _singl.containsKey(_getKey(S, tag));
bool isRegistered<S>({String? tag}) => _singl.containsKey(_getKey(S, tag));
/// Checks if a lazy factory callback ([Get.lazyPut()] that returns an
/// Instance<[S]> is registered in memory.
/// - [tag] is optional, if you used a [tag] to register the lazy Instance.
bool isPrepared<S>({String tag}) {
bool isPrepared<S>({String? tag}) {
final newKey = _getKey(S, tag);
final builder = _getDependency<S>(tag: tag, key: newKey);
... ... @@ -481,14 +481,14 @@ typedef AsyncInstanceBuilderCallback<S> = Future<S> Function();
class _InstanceBuilderFactory<S> {
/// Marks the Builder as a single instance.
/// For reusing [dependency] instead of [builderFunc]
bool isSingleton;
bool? isSingleton;
/// When fenix mode is avaliable, when a new instance is need
/// Instance manager will recreate a new instance of S
bool fenix;
/// Stores the actual object instance when [isSingleton]=true.
S dependency;
S? dependency;
/// Generates (and regenerates) the instance when [isSingleton]=false.
/// Usually used by factory methods
... ... @@ -500,7 +500,7 @@ class _InstanceBuilderFactory<S> {
bool isInit = false;
String tag;
String? tag;
_InstanceBuilderFactory(
this.isSingleton,
... ... @@ -520,8 +520,8 @@ class _InstanceBuilderFactory<S> {
}
/// Gets the actual instance by it's [builderFunc] or the persisted instance.
S getDependency() {
if (isSingleton) {
S? getDependency() {
if (isSingleton!) {
if (dependency == null) {
_showInitLog();
dependency = builderFunc();
... ...
... ... @@ -5,11 +5,11 @@ import '../../get_core/get_core.dart';
/// methods.
/// Used in [DisposableInterface] to avoid the danger of overriding onStart.
class _InternalFinalCallback<T> {
ValueUpdater<T> _callback;
ValueUpdater<T>? _callback;
_InternalFinalCallback({ValueUpdater<T> callback}) : _callback = callback;
_InternalFinalCallback({ValueUpdater<T>? callback}) : _callback = callback;
T call() => _callback.call();
T call() => _callback!.call();
}
/// The [GetLifeCycle]
... ...
... ... @@ -14,8 +14,8 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
this.modalBarrierColor,
this.isDismissible = true,
this.enableDrag = true,
@required this.isScrollControlled,
RouteSettings settings,
required this.isScrollControlled,
RouteSettings? settings,
this.enterBottomSheetDuration = const Duration(milliseconds: 250),
this.exitBottomSheetDuration = const Duration(milliseconds: 200),
}) : assert(isScrollControlled != null),
... ... @@ -23,15 +23,15 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
assert(isDismissible != null),
assert(enableDrag != null),
super(settings: settings);
final bool isPersistent;
final WidgetBuilder builder;
final ThemeData theme;
final bool? isPersistent;
final WidgetBuilder? builder;
final ThemeData? theme;
final bool isScrollControlled;
final Color backgroundColor;
final double elevation;
final ShapeBorder shape;
final Clip clipBehavior;
final Color modalBarrierColor;
final Color? backgroundColor;
final double? elevation;
final ShapeBorder? shape;
final Clip? clipBehavior;
final Color? modalBarrierColor;
final bool isDismissible;
final bool enableDrag;
final String name;
... ... @@ -47,21 +47,21 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
bool get barrierDismissible => isDismissible;
@override
final String barrierLabel;
final String? barrierLabel;
@override
Color get barrierColor => modalBarrierColor ?? Colors.black54;
AnimationController _animationController;
AnimationController? _animationController;
@override
AnimationController createAnimationController() {
assert(_animationController == null);
_animationController =
BottomSheet.createAnimationController(navigator.overlay);
_animationController.duration = enterBottomSheetDuration;
_animationController.reverseDuration = exitBottomSheetDuration;
return _animationController;
BottomSheet.createAnimationController(navigator!.overlay!);
_animationController!.duration = enterBottomSheetDuration;
_animationController!.reverseDuration = exitBottomSheetDuration;
return _animationController!;
}
@override
... ... @@ -91,14 +91,14 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
),
),
);
if (theme != null) bottomSheet = Theme(data: theme, child: bottomSheet);
if (theme != null) bottomSheet = Theme(data: theme!, child: bottomSheet);
return bottomSheet;
}
}
class _GetModalBottomSheet<T> extends StatefulWidget {
const _GetModalBottomSheet({
Key key,
Key? key,
this.route,
this.backgroundColor,
this.elevation,
... ... @@ -111,12 +111,12 @@ class _GetModalBottomSheet<T> extends StatefulWidget {
assert(enableDrag != null),
super(key: key);
final bool isPersistent;
final GetModalBottomSheetRoute<T> route;
final GetModalBottomSheetRoute<T>? route;
final bool isScrollControlled;
final Color backgroundColor;
final double elevation;
final ShapeBorder shape;
final Clip clipBehavior;
final Color? backgroundColor;
final double? elevation;
final ShapeBorder? shape;
final Clip? clipBehavior;
final bool enableDrag;
@override
... ... @@ -142,13 +142,13 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> {
final routeLabel = _getRouteLabel(localizations);
return AnimatedBuilder(
animation: widget.route.animation,
animation: widget.route!.animation!,
builder: (context, child) {
// Disable the initial animation when accessible navigation is on so
// that the semantics are added to the tree at the correct time.
final animationValue = mediaQuery.accessibleNavigation
? 1.0
: widget.route.animation.value;
: widget.route!.animation!.value;
return Semantics(
scopesRoute: true,
namesRoute: true,
... ... @@ -160,13 +160,13 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> {
animationValue, widget.isScrollControlled),
child: widget.isPersistent == false
? BottomSheet(
animationController: widget.route._animationController,
animationController: widget.route!._animationController,
onClosing: () {
if (widget.route.isCurrent) {
if (widget.route!.isCurrent) {
Navigator.pop(context);
}
},
builder: widget.route.builder,
builder: widget.route!.builder!,
backgroundColor: widget.backgroundColor,
elevation: widget.elevation,
shape: widget.shape,
... ... @@ -176,13 +176,13 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> {
: Scaffold(
bottomSheet: BottomSheet(
animationController:
widget.route._animationController,
widget.route!._animationController,
onClosing: () {
// if (widget.route.isCurrent) {
// Navigator.pop(context);
// }
},
builder: widget.route.builder,
builder: widget.route!.builder!,
backgroundColor: widget.backgroundColor,
elevation: widget.elevation,
shape: widget.shape,
... ... @@ -199,7 +199,7 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> {
class _GetPerModalBottomSheet<T> extends StatefulWidget {
const _GetPerModalBottomSheet({
Key key,
Key? key,
this.route,
this.isPersistent,
this.backgroundColor,
... ... @@ -211,13 +211,13 @@ class _GetPerModalBottomSheet<T> extends StatefulWidget {
}) : assert(isScrollControlled != null),
assert(enableDrag != null),
super(key: key);
final bool isPersistent;
final GetModalBottomSheetRoute<T> route;
final bool? isPersistent;
final GetModalBottomSheetRoute<T>? route;
final bool isScrollControlled;
final Color backgroundColor;
final double elevation;
final ShapeBorder shape;
final Clip clipBehavior;
final Color? backgroundColor;
final double? elevation;
final ShapeBorder? shape;
final Clip? clipBehavior;
final bool enableDrag;
@override
... ... @@ -247,13 +247,13 @@ class _GetPerModalBottomSheetState<T>
final routeLabel = _getRouteLabel(localizations);
return AnimatedBuilder(
animation: widget.route.animation,
animation: widget.route!.animation!,
builder: (context, child) {
// Disable the initial animation when accessible navigation is on so
// that the semantics are added to the tree at the correct time.
final animationValue = mediaQuery.accessibleNavigation
? 1.0
: widget.route.animation.value;
: widget.route!.animation!.value;
return Semantics(
scopesRoute: true,
namesRoute: true,
... ... @@ -265,13 +265,13 @@ class _GetPerModalBottomSheetState<T>
animationValue, widget.isScrollControlled),
child: widget.isPersistent == false
? BottomSheet(
animationController: widget.route._animationController,
animationController: widget.route!._animationController,
onClosing: () {
if (widget.route.isCurrent) {
if (widget.route!.isCurrent) {
Navigator.pop(context);
}
},
builder: widget.route.builder,
builder: widget.route!.builder!,
backgroundColor: widget.backgroundColor,
elevation: widget.elevation,
shape: widget.shape,
... ... @@ -281,13 +281,13 @@ class _GetPerModalBottomSheetState<T>
: Scaffold(
bottomSheet: BottomSheet(
animationController:
widget.route._animationController,
widget.route!._animationController,
onClosing: () {
// if (widget.route.isCurrent) {
// Navigator.pop(context);
// }
},
builder: widget.route.builder,
builder: widget.route!.builder!,
backgroundColor: widget.backgroundColor,
elevation: widget.elevation,
shape: widget.shape,
... ...
... ... @@ -4,13 +4,13 @@ import '../../../get_instance/src/get_instance.dart';
class GetDialogRoute<T> extends PopupRoute<T> {
GetDialogRoute({
@required RoutePageBuilder pageBuilder,
required RoutePageBuilder pageBuilder,
bool barrierDismissible = true,
String barrierLabel,
String? barrierLabel,
Color barrierColor = const Color(0x80000000),
Duration transitionDuration = const Duration(milliseconds: 200),
RouteTransitionsBuilder transitionBuilder,
RouteSettings settings,
RouteTransitionsBuilder? transitionBuilder,
RouteSettings? settings,
}) : assert(barrierDismissible != null),
widget = pageBuilder,
name = "DIALOG: ${pageBuilder.hashCode}",
... ... @@ -32,15 +32,15 @@ class GetDialogRoute<T> extends PopupRoute<T> {
@override
void dispose() {
if (Get.smartManagement != SmartManagement.onlyBuilder) {
WidgetsBinding.instance.addPostFrameCallback(
WidgetsBinding.instance!.addPostFrameCallback(
(_) => GetInstance().removeDependencyByRoute(name));
}
super.dispose();
}
@override
String get barrierLabel => _barrierLabel;
final String _barrierLabel;
String? get barrierLabel => _barrierLabel;
final String? _barrierLabel;
@override
Color get barrierColor => _barrierColor;
... ... @@ -50,7 +50,7 @@ class GetDialogRoute<T> extends PopupRoute<T> {
Duration get transitionDuration => _transitionDuration;
final Duration _transitionDuration;
final RouteTransitionsBuilder _transitionBuilder;
final RouteTransitionsBuilder? _transitionBuilder;
@override
Widget buildPage(BuildContext context, Animation<double> animation,
... ... @@ -73,6 +73,6 @@ class GetDialogRoute<T> extends PopupRoute<T> {
),
child: child);
} // Some default transition
return _transitionBuilder(context, animation, secondaryAnimation, child);
return _transitionBuilder!(context, animation, secondaryAnimation, child);
}
}
... ...
... ... @@ -14,42 +14,42 @@ import 'routes/transitions_type.dart';
extension ExtensionSnackbar on GetInterface {
void rawSnackbar({
String title,
String message,
Widget titleText,
Widget messageText,
Widget icon,
String? title,
String? message,
Widget? titleText,
Widget? messageText,
Widget? icon,
bool instantInit = true,
bool shouldIconPulse = true,
double maxWidth,
double? maxWidth,
EdgeInsets margin = const EdgeInsets.all(0.0),
EdgeInsets padding = const EdgeInsets.all(16),
double borderRadius = 0.0,
Color borderColor,
Color? borderColor,
double borderWidth = 1.0,
Color backgroundColor = const Color(0xFF303030),
Color leftBarIndicatorColor,
List<BoxShadow> boxShadows,
Gradient backgroundGradient,
Widget mainButton,
OnTap onTap,
Color? leftBarIndicatorColor,
List<BoxShadow>? boxShadows,
Gradient? backgroundGradient,
Widget? mainButton,
OnTap? onTap,
Duration duration = const Duration(seconds: 3),
bool isDismissible = true,
SnackDismissDirection dismissDirection = SnackDismissDirection.VERTICAL,
bool showProgressIndicator = false,
AnimationController progressIndicatorController,
Color progressIndicatorBackgroundColor,
Animation<Color> progressIndicatorValueColor,
AnimationController? progressIndicatorController,
Color? progressIndicatorBackgroundColor,
Animation<Color>? progressIndicatorValueColor,
SnackPosition snackPosition = SnackPosition.BOTTOM,
SnackStyle snackStyle = SnackStyle.FLOATING,
Curve forwardAnimationCurve = Curves.easeOutCirc,
Curve reverseAnimationCurve = Curves.easeOutCirc,
Duration animationDuration = const Duration(seconds: 1),
SnackbarStatusCallback snackbarStatus,
double barBlur = 0.0,
SnackbarStatusCallback? snackbarStatus,
double? barBlur = 0.0,
double overlayBlur = 0.0,
Color overlayColor,
Form userInputForm,
Color? overlayColor,
Form? userInputForm,
}) async {
final getBar = GetBar(
snackbarStatus: snackbarStatus,
... ... @@ -76,7 +76,7 @@ extension ExtensionSnackbar on GetInterface {
onTap: onTap,
isDismissible: isDismissible,
dismissDirection: dismissDirection,
showProgressIndicator: showProgressIndicator ?? false,
showProgressIndicator: showProgressIndicator,
progressIndicatorController: progressIndicatorController,
progressIndicatorBackgroundColor: progressIndicatorBackgroundColor,
progressIndicatorValueColor: progressIndicatorValueColor,
... ... @@ -92,56 +92,56 @@ extension ExtensionSnackbar on GetInterface {
if (instantInit) {
getBar.show();
} else {
SchedulerBinding.instance.addPostFrameCallback((_) {
SchedulerBinding.instance!.addPostFrameCallback((_) {
getBar.show();
});
}
}
Future<T> showSnackbar<T>(GetBar snackbar) {
Future<T?>? showSnackbar<T>(GetBar snackbar) {
return key?.currentState?.push(SnackRoute<T>(snack: snackbar));
}
void snackbar<T>(
String title,
String message, {
Color colorText,
Duration duration,
Color? colorText,
Duration? duration,
/// with instantInit = false you can put snackbar on initState
bool instantInit = true,
SnackPosition snackPosition,
Widget titleText,
Widget messageText,
Widget icon,
bool shouldIconPulse,
double maxWidth,
EdgeInsets margin,
EdgeInsets padding,
double borderRadius,
Color borderColor,
double borderWidth,
Color backgroundColor,
Color leftBarIndicatorColor,
List<BoxShadow> boxShadows,
Gradient backgroundGradient,
TextButton mainButton,
OnTap onTap,
bool isDismissible,
bool showProgressIndicator,
SnackDismissDirection dismissDirection,
AnimationController progressIndicatorController,
Color progressIndicatorBackgroundColor,
Animation<Color> progressIndicatorValueColor,
SnackStyle snackStyle,
Curve forwardAnimationCurve,
Curve reverseAnimationCurve,
Duration animationDuration,
double barBlur,
double overlayBlur,
SnackbarStatusCallback snackbarStatus,
Color overlayColor,
Form userInputForm,
SnackPosition? snackPosition,
Widget? titleText,
Widget? messageText,
Widget? icon,
bool? shouldIconPulse,
double? maxWidth,
EdgeInsets? margin,
EdgeInsets? padding,
double? borderRadius,
Color? borderColor,
double? borderWidth,
Color? backgroundColor,
Color? leftBarIndicatorColor,
List<BoxShadow>? boxShadows,
Gradient? backgroundGradient,
TextButton? mainButton,
OnTap? onTap,
bool? isDismissible,
bool? showProgressIndicator,
SnackDismissDirection? dismissDirection,
AnimationController? progressIndicatorController,
Color? progressIndicatorBackgroundColor,
Animation<Color>? progressIndicatorValueColor,
SnackStyle? snackStyle,
Curve? forwardAnimationCurve,
Curve? reverseAnimationCurve,
Duration? animationDuration,
double? barBlur,
double? overlayBlur,
SnackbarStatusCallback? snackbarStatus,
Color? overlayColor,
Form? userInputForm,
}) async {
final getBar = GetBar(
snackbarStatus: snackbarStatus,
... ... @@ -200,7 +200,7 @@ extension ExtensionSnackbar on GetInterface {
showSnackbar<T>(getBar);
} else {
routing.isSnackbar = true;
SchedulerBinding.instance.addPostFrameCallback((_) {
SchedulerBinding.instance!.addPostFrameCallback((_) {
showSnackbar<T>(getBar);
});
}
... ... @@ -212,26 +212,26 @@ extension ExtensionDialog on GetInterface {
/// You can pass a [transitionDuration] and/or [transitionCurve],
/// overriding the defaults when the dialog shows up and closes.
/// When the dialog closes, uses those animations in reverse.
Future<T> dialog<T>(
Future<T?> dialog<T>(
Widget widget, {
bool barrierDismissible = true,
Color barrierColor,
Color? barrierColor,
bool useSafeArea = true,
bool useRootNavigator = true,
Object arguments,
Duration transitionDuration,
Curve transitionCurve,
String name,
RouteSettings routeSettings,
Object? arguments,
Duration? transitionDuration,
Curve? transitionCurve,
String? name,
RouteSettings? routeSettings,
}) {
assert(widget != null);
assert(barrierDismissible != null);
assert(useSafeArea != null);
assert(useRootNavigator != null);
assert(debugCheckHasMaterialLocalizations(context));
assert(debugCheckHasMaterialLocalizations(context!));
// final theme = Theme.of(context, shadowThemeOnly: true);
final theme = Theme.of(context);
final theme = Theme.of(context!);
return generalDialog<T>(
pageBuilder: (buildContext, animation, secondaryAnimation) {
final pageChild = widget;
... ... @@ -246,7 +246,7 @@ extension ExtensionDialog on GetInterface {
return dialog;
},
barrierDismissible: barrierDismissible,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
barrierLabel: MaterialLocalizations.of(context!).modalBarrierDismissLabel,
barrierColor: barrierColor ?? Colors.black54,
transitionDuration: transitionDuration ?? defaultDialogTransitionDuration,
transitionBuilder: (context, animation, secondaryAnimation, child) {
... ... @@ -265,20 +265,20 @@ extension ExtensionDialog on GetInterface {
}
/// Api from showGeneralDialog with no context
Future<T> generalDialog<T>({
@required RoutePageBuilder pageBuilder,
Future<T?> generalDialog<T>({
required RoutePageBuilder pageBuilder,
bool barrierDismissible = false,
String barrierLabel,
String? barrierLabel,
Color barrierColor = const Color(0x80000000),
Duration transitionDuration = const Duration(milliseconds: 200),
RouteTransitionsBuilder transitionBuilder,
RouteTransitionsBuilder? transitionBuilder,
bool useRootNavigator = true,
RouteSettings routeSettings,
RouteSettings? routeSettings,
}) {
assert(pageBuilder != null);
assert(useRootNavigator != null);
assert(!barrierDismissible || barrierLabel != null);
return Navigator.of(overlayContext, rootNavigator: useRootNavigator)
return Navigator.of(overlayContext!, rootNavigator: useRootNavigator)
.push<T>(GetDialogRoute<T>(
pageBuilder: pageBuilder,
barrierDismissible: barrierDismissible,
... ... @@ -291,32 +291,32 @@ extension ExtensionDialog on GetInterface {
}
/// Custom UI Dialog.
Future<T> defaultDialog<T>({
Future<T?> defaultDialog<T>({
String title = "Alert",
TextStyle titleStyle,
Widget content,
VoidCallback onConfirm,
VoidCallback onCancel,
VoidCallback onCustom,
Color cancelTextColor,
Color confirmTextColor,
String textConfirm,
String textCancel,
String textCustom,
Widget confirm,
Widget cancel,
Widget custom,
Color backgroundColor,
TextStyle? titleStyle,
Widget? content,
VoidCallback? onConfirm,
VoidCallback? onCancel,
VoidCallback? onCustom,
Color? cancelTextColor,
Color? confirmTextColor,
String? textConfirm,
String? textCancel,
String? textCustom,
Widget? confirm,
Widget? cancel,
Widget? custom,
Color? backgroundColor,
bool barrierDismissible = true,
Color buttonColor,
Color? buttonColor,
String middleText = "Dialog made in 3 lines of code",
TextStyle middleTextStyle,
TextStyle? middleTextStyle,
double radius = 20.0,
// ThemeData themeData,
List<Widget> actions,
List<Widget>? actions,
// onWillPop Scope
WillPopCallback onWillPop,
WillPopCallback? onWillPop,
}) {
var leanCancel = onCancel != null || textCancel != null;
var leanConfirm = onConfirm != null || textConfirm != null;
... ... @@ -332,7 +332,7 @@ extension ExtensionDialog on GetInterface {
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 8),
shape: RoundedRectangleBorder(
side: BorderSide(
color: buttonColor ?? theme.accentColor,
color: buttonColor ?? theme!.accentColor,
width: 2,
style: BorderStyle.solid),
borderRadius: BorderRadius.circular(100)),
... ... @@ -343,7 +343,7 @@ extension ExtensionDialog on GetInterface {
},
child: Text(
textCancel ?? "Cancel",
style: TextStyle(color: cancelTextColor ?? theme.accentColor),
style: TextStyle(color: cancelTextColor ?? theme!.accentColor),
),
));
}
... ... @@ -356,14 +356,14 @@ extension ExtensionDialog on GetInterface {
style: TextButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
//color: buttonColor ?? theme.accentColor,
backgroundColor: buttonColor ?? theme.accentColor,
backgroundColor: buttonColor ?? theme!.accentColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100)),
),
child: Text(
textConfirm ?? "Ok",
style:
TextStyle(color: confirmTextColor ?? theme.backgroundColor),
TextStyle(color: confirmTextColor ?? theme!.backgroundColor),
),
onPressed: () {
onConfirm?.call();
... ... @@ -374,7 +374,7 @@ extension ExtensionDialog on GetInterface {
Widget baseAlertDialog = AlertDialog(
titlePadding: EdgeInsets.all(8),
contentPadding: EdgeInsets.all(8),
backgroundColor: backgroundColor ?? theme.dialogBackgroundColor,
backgroundColor: backgroundColor ?? theme!.dialogBackgroundColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(radius))),
title: Text(title, textAlign: TextAlign.center, style: titleStyle),
... ... @@ -420,22 +420,22 @@ extension ExtensionDialog on GetInterface {
}
extension ExtensionBottomSheet on GetInterface {
Future<T> bottomSheet<T>(
Future<T?> bottomSheet<T>(
Widget bottomsheet, {
Color backgroundColor,
double elevation,
Color? backgroundColor,
double? elevation,
bool persistent = true,
ShapeBorder shape,
Clip clipBehavior,
Color barrierColor,
bool ignoreSafeArea,
ShapeBorder? shape,
Clip? clipBehavior,
Color? barrierColor,
bool? ignoreSafeArea,
bool isScrollControlled = false,
bool useRootNavigator = false,
bool isDismissible = true,
bool enableDrag = true,
RouteSettings settings,
Duration enterBottomSheetDuration,
Duration exitBottomSheetDuration,
RouteSettings? settings,
Duration? enterBottomSheetDuration,
Duration? exitBottomSheetDuration,
}) {
assert(bottomsheet != null);
assert(persistent != null);
... ... @@ -444,15 +444,15 @@ extension ExtensionBottomSheet on GetInterface {
assert(isDismissible != null);
assert(enableDrag != null);
return Navigator.of(overlayContext, rootNavigator: useRootNavigator)
return Navigator.of(overlayContext!, rootNavigator: useRootNavigator)
.push(GetModalBottomSheetRoute<T>(
builder: (_) => bottomsheet,
isPersistent: persistent,
// theme: Theme.of(key.currentContext, shadowThemeOnly: true),
theme: Theme.of(key.currentContext),
theme: Theme.of(key!.currentContext!),
isScrollControlled: isScrollControlled,
barrierLabel:
MaterialLocalizations.of(key.currentContext).modalBarrierDismissLabel,
barrierLabel: MaterialLocalizations.of(key!.currentContext!)
.modalBarrierDismissLabel,
backgroundColor: backgroundColor ?? Colors.transparent,
elevation: elevation,
shape: shape,
... ... @@ -491,18 +491,18 @@ extension GetNavigation on GetInterface {
///
/// By default, GetX will prevent you from push a route that you already in,
/// if you want to push anyway, set [preventDuplicates] to false
Future<T> to<T>(
Future<T?>? to<T>(
dynamic page, {
bool opaque,
Transition transition,
Curve curve,
Duration duration,
int id,
bool? opaque,
Transition? transition,
Curve? curve,
Duration? duration,
int? id,
bool fullscreenDialog = false,
dynamic arguments,
Bindings binding,
Bindings? binding,
bool preventDuplicates = true,
bool popGesture,
bool? popGesture,
}) {
var routeName = "/${page.runtimeType.toString()}";
if (preventDuplicates && routeName == currentRoute) {
... ... @@ -558,12 +558,12 @@ you can only use widgets and widget functions here''';
/// if you want to push anyway, set [preventDuplicates] to false
///
/// Note: Always put a slash on the route ('/page1'), to avoid unnexpected errors
Future<T> toNamed<T>(
Future<T?>? toNamed<T>(
String page, {
dynamic arguments,
int id,
int? id,
bool preventDuplicates = true,
Map<String, String> parameters,
Map<String, String>? parameters,
}) {
if (preventDuplicates && page == currentRoute) {
return null;
... ... @@ -596,12 +596,12 @@ you can only use widgets and widget functions here''';
/// if you want to push anyway, set [preventDuplicates] to false
///
/// Note: Always put a slash on the route ('/page1'), to avoid unnexpected errors
Future<T> offNamed<T>(
Future<T?>? offNamed<T>(
String page, {
dynamic arguments,
int id,
int? id,
bool preventDuplicates = true,
Map<String, String> parameters,
Map<String, String>? parameters,
}) {
if (preventDuplicates && page == currentRoute) {
return null;
... ... @@ -630,7 +630,7 @@ you can only use widgets and widget functions here''';
/// or also like this:
/// `Get.until((route) => !Get.isDialogOpen())`, to make sure the
/// dialog is closed
void until(RoutePredicate predicate, {int id}) {
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 global(id)?.currentState?.popUntil(predicate);
... ... @@ -654,7 +654,7 @@ you can only use widgets and widget functions here''';
/// or also like this:
/// `Get.until((route) => !Get.isDialogOpen())`, to make sure the dialog
/// is closed
Future<T> offUntil<T>(Route<T> page, RoutePredicate predicate, {int id}) {
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 global(id)?.currentState?.pushAndRemoveUntil<T>(page, predicate);
... ... @@ -678,12 +678,12 @@ you can only use widgets and widget functions here''';
/// to make sure the dialog is closed
///
/// Note: Always put a slash on the route name ('/page1'), to avoid unexpected errors
Future<T> offNamedUntil<T>(
Future<T?>? offNamedUntil<T>(
String page,
RoutePredicate predicate, {
int id,
int? id,
dynamic arguments,
Map<String, String> parameters,
Map<String, String>? parameters,
}) {
if (parameters != null) {
final uri = Uri(path: page, queryParameters: parameters);
... ... @@ -708,12 +708,12 @@ you can only use widgets and widget functions here''';
/// The `offNamed()` pop a page, and goes to the next. The
/// `offAndToNamed()` goes to the next page, and removes the previous one.
/// The route transition animation is different.
Future<T> offAndToNamed<T>(
Future<T?>? offAndToNamed<T>(
String page, {
dynamic arguments,
int id,
int? id,
dynamic result,
Map<String, String> parameters,
Map<String, String>? parameters,
}) {
if (parameters != null) {
final uri = Uri(path: page, queryParameters: parameters);
... ... @@ -732,7 +732,7 @@ you can only use widgets and widget functions here''';
///
/// [id] is for when you are using nested navigation,
/// as explained in documentation
void removeRoute(Route<dynamic> route, {int id}) {
void removeRoute(Route<dynamic> route, {int? id}) {
return global(id)?.currentState?.removeRoute(route);
}
... ... @@ -756,12 +756,12 @@ you can only use widgets and widget functions here''';
/// as explained in documentation
///
/// Note: Always put a slash on the route ('/page1'), to avoid unexpected errors
Future<T> offAllNamed<T>(
Future<T?>? offAllNamed<T>(
String newRouteName, {
RoutePredicate predicate,
RoutePredicate? predicate,
dynamic arguments,
int id,
Map<String, String> parameters,
int? id,
Map<String, String>? parameters,
}) {
if (parameters != null) {
final uri = Uri(path: newRouteName, queryParameters: parameters);
... ... @@ -777,11 +777,11 @@ you can only use widgets and widget functions here''';
/// Returns true if a Snackbar, Dialog or BottomSheet is currently OPEN
bool get isOverlaysOpen =>
(isSnackbarOpen || isDialogOpen || isBottomSheetOpen);
(isSnackbarOpen! || isDialogOpen! || isBottomSheetOpen!);
/// Returns true if there is no Snackbar, Dialog or BottomSheet open
bool get isOverlaysClosed =>
(!isSnackbarOpen && !isDialogOpen && !isBottomSheetOpen);
(!isSnackbarOpen! && !isDialogOpen! && !isBottomSheetOpen!);
/// **Navigation.popUntil()** shortcut.<br><br>
///
... ... @@ -796,10 +796,10 @@ you can only use widgets and widget functions here''';
/// It has the advantage of not needing context, so you can call
/// from your business logic.
void back<T>({
T result,
T? result,
bool closeOverlays = false,
bool canPop = true,
int id,
int? id,
}) {
if (closeOverlays && isOverlaysOpen) {
navigator?.popUntil((route) {
... ... @@ -821,7 +821,7 @@ you can only use widgets and widget functions here''';
///
/// [id] is for when you are using nested navigation,
/// as explained in documentation
void close(int times, [int id]) {
void close(int times, [int? id]) {
if ((times == null) || (times < 1)) {
times = 1;
}
... ... @@ -856,18 +856,18 @@ you can only use widgets and widget functions here''';
///
/// By default, GetX will prevent you from push a route that you already in,
/// if you want to push anyway, set [preventDuplicates] to false
Future<T> off<T>(
Future<T?>? off<T>(
dynamic page, {
bool opaque = false,
Transition transition,
Curve curve,
bool popGesture,
int id,
Transition? transition,
Curve? curve,
bool? popGesture,
int? id,
dynamic arguments,
Bindings binding,
Bindings? binding,
bool fullscreenDialog = false,
bool preventDuplicates = true,
Duration duration,
Duration? duration,
}) {
var routeName = "/${page.runtimeType.toString()}";
if (preventDuplicates && routeName == currentRoute) {
... ... @@ -917,18 +917,18 @@ you can only use widgets and widget functions here''';
///
/// By default, GetX will prevent you from push a route that you already in,
/// if you want to push anyway, set [preventDuplicates] to false
Future<T> offAll<T>(
Future<T?>? offAll<T>(
dynamic page, {
RoutePredicate predicate,
RoutePredicate? predicate,
bool opaque = false,
bool popGesture,
int id,
bool? popGesture,
int? id,
dynamic arguments,
Bindings binding,
Bindings? binding,
bool fullscreenDialog = false,
Transition transition,
Curve curve,
Duration duration,
Transition? transition,
Curve? curve,
Duration? duration,
}) {
var routeName = "/${page.runtimeType.toString()}";
... ... @@ -948,32 +948,32 @@ you can only use widgets and widget functions here''';
predicate ?? (route) => false);
}
void addPages(List<GetPage> getPages) {
void addPages(List<GetPage>? getPages) {
if (getPages != null) {
if (routeTree == null) {
routeTree = ParseRouteTree();
}
routeTree.addRoutes(getPages);
routeTree!.addRoutes(getPages);
}
}
void addPage(GetPage getPage) {
if (getPage != null) {
if (routeTree == null) routeTree = ParseRouteTree();
routeTree.addRoute(getPage);
routeTree!.addRoute(getPage);
}
}
/// change default config of Get
void config(
{bool enableLog,
LogWriterCallback logWriterCallback,
bool defaultPopGesture,
bool defaultOpaqueRoute,
Duration defaultDurationTransition,
bool defaultGlobalState,
Transition defaultTransition}) {
{bool? enableLog,
LogWriterCallback? logWriterCallback,
bool? defaultPopGesture,
bool? defaultOpaqueRoute,
Duration? defaultDurationTransition,
bool? defaultGlobalState,
Transition? defaultTransition}) {
if (enableLog != null) {
Get.isLogEnable = enableLog;
}
... ... @@ -1014,7 +1014,7 @@ you can only use widgets and widget functions here''';
/// Your entire application will be rebuilt, and touch events will not
/// work until the end of rendering.
void forceAppUpdate() {
engine.performReassemble();
engine!.performReassemble();
}
void appUpdate() => getxController.update();
... ... @@ -1027,18 +1027,18 @@ you can only use widgets and widget functions here''';
getxController.setThemeMode(themeMode);
}
GlobalKey<NavigatorState> addKey(GlobalKey<NavigatorState> newKey) {
GlobalKey<NavigatorState>? addKey(GlobalKey<NavigatorState>? newKey) {
getxController.key = newKey;
return key;
}
GlobalKey<NavigatorState> nestedKey(int key) {
GlobalKey<NavigatorState>? nestedKey(int key) {
keys.putIfAbsent(key, () => GlobalKey<NavigatorState>());
return keys[key];
}
GlobalKey<NavigatorState> global(int k) {
GlobalKey<NavigatorState> _key;
GlobalKey<NavigatorState>? global(int? k) {
GlobalKey<NavigatorState>? _key;
if (k == null) {
_key = key;
} else {
... ... @@ -1048,7 +1048,7 @@ you can only use widgets and widget functions here''';
_key = keys[k];
}
if (_key.currentContext == null && !testMode) {
if (_key!.currentContext == null && !testMode) {
throw """You are trying to use contextless navigation without
a GetMaterialApp or Get.key.
If you are testing your app, you can use:
... ... @@ -1065,7 +1065,7 @@ you can only use widgets and widget functions here''';
Since version 2.8 it is possible to access the properties
[Get.arguments] and [Get.currentRoute] directly.
[routeSettings] is useless and should not be used.''')
RouteSettings get routeSettings => null;
RouteSettings? get routeSettings => null;
/// give current arguments
dynamic get arguments => routing.args;
... ... @@ -1077,16 +1077,16 @@ Since version 2.8 it is possible to access the properties
String get previousRoute => routing.previous;
/// check if snackbar is open
bool get isSnackbarOpen => routing.isSnackbar;
bool? get isSnackbarOpen => routing.isSnackbar;
/// check if dialog is open
bool get isDialogOpen => routing.isDialog;
bool? get isDialogOpen => routing.isDialog;
/// check if bottomsheet is open
bool get isBottomSheetOpen => routing.isBottomSheet;
bool? get isBottomSheetOpen => routing.isBottomSheet;
/// check a raw current route
Route<dynamic> get rawRoute => routing.route;
Route<dynamic>? get rawRoute => routing.route;
/// check if popGesture is enable
bool get isPopGestureEnable => defaultPopGesture;
... ... @@ -1095,11 +1095,11 @@ Since version 2.8 it is possible to access the properties
bool get isOpaqueRouteDefault => defaultOpaqueRoute;
/// give access to currentContext
BuildContext get context => key?.currentContext;
BuildContext? get context => key?.currentContext;
/// give access to current Overlay Context
BuildContext get overlayContext {
BuildContext overlay;
BuildContext? get overlayContext {
BuildContext? overlay;
key?.currentState?.overlay?.context?.visitChildElements((element) {
overlay = element;
});
... ... @@ -1107,16 +1107,16 @@ Since version 2.8 it is possible to access the properties
}
/// give access to Theme.of(context)
ThemeData get theme {
ThemeData _theme;
ThemeData? get theme {
ThemeData? _theme;
if (context != null) {
_theme = Theme.of(context);
_theme = Theme.of(context!);
}
return _theme;
}
///The current [WidgetsBinding]
WidgetsBinding get engine {
WidgetsBinding? get engine {
if (WidgetsBinding.instance == null) {
WidgetsFlutterBinding();
}
... ... @@ -1153,23 +1153,23 @@ Since version 2.8 it is possible to access the properties
double get textScaleFactor => ui.window.textScaleFactor;
/// give access to TextTheme.of(context)
TextTheme get textTheme => theme?.textTheme;
TextTheme? get textTheme => theme?.textTheme;
/// give access to Mediaquery.of(context)
MediaQueryData get mediaQuery => MediaQuery.of(context);
MediaQueryData get mediaQuery => MediaQuery.of(context!);
/// Check if dark mode theme is enable
bool get isDarkMode => (theme.brightness == Brightness.dark);
bool get isDarkMode => (theme!.brightness == Brightness.dark);
/// Check if dark mode theme is enable on platform on android Q+
bool get isPlatformDarkMode =>
(ui.window.platformBrightness == Brightness.dark);
/// give access to Theme.of(context).iconTheme.color
Color get iconColor => theme?.iconTheme?.color;
Color? get iconColor => theme?.iconTheme?.color;
/// give access to FocusScope.of(context)
FocusNode get focusScope => FocusManager.instance.primaryFocus;
FocusNode? get focusScope => FocusManager.instance.primaryFocus;
// /// give access to Immutable MediaQuery.of(context).size.height
// double get height => MediaQuery.of(context).size.height;
... ... @@ -1177,16 +1177,16 @@ Since version 2.8 it is possible to access the properties
// /// give access to Immutable MediaQuery.of(context).size.width
// double get width => MediaQuery.of(context).size.width;
GlobalKey<NavigatorState> get key => getxController?.key;
GlobalKey<NavigatorState>? get key => getxController.key;
Map<int, GlobalKey<NavigatorState>> get keys => getxController?.keys;
Map<int, GlobalKey<NavigatorState>> get keys => getxController.keys;
GetMaterialController get rootController => getxController;
bool get defaultPopGesture => getxController.defaultPopGesture;
bool get defaultOpaqueRoute => getxController.defaultOpaqueRoute;
Transition get defaultTransition => getxController.defaultTransition;
Transition? get defaultTransition => getxController.defaultTransition;
Duration get defaultTransitionDuration {
return getxController.defaultTransitionDuration;
... ... @@ -1204,15 +1204,15 @@ Since version 2.8 it is possible to access the properties
Routing get routing => getxController.routing;
Map<String, String> get parameters => getxController.parameters;
set parameters(Map<String, String> newParameters) =>
Map<String?, String> get parameters => getxController.parameters;
set parameters(Map<String?, String> newParameters) =>
getxController.parameters = newParameters;
ParseRouteTree get routeTree => getxController.routeTree;
set routeTree(ParseRouteTree tree) => getxController.routeTree = tree;
CustomTransition get customTransition => getxController.customTransition;
set customTransition(CustomTransition newTransition) =>
CustomTransition? get customTransition => getxController.customTransition;
set customTransition(CustomTransition? newTransition) =>
getxController.customTransition = newTransition;
bool get testMode => getxController.testMode;
... ... @@ -1224,4 +1224,4 @@ Since version 2.8 it is possible to access the properties
/// It replaces the Flutter Navigator, but needs no context.
/// You can to use navigator.push(YourRoute()) rather
/// Navigator.push(context, YourRoute());
NavigatorState get navigator => GetNavigation(Get).key.currentState;
NavigatorState? get navigator => GetNavigation(Get).key!.currentState;
... ...
... ... @@ -10,16 +10,16 @@ import 'root_controller.dart';
class GetCupertinoApp extends StatelessWidget {
const GetCupertinoApp({
Key key,
Key? key,
this.theme,
this.navigatorKey,
this.home,
this.routes = const <String, WidgetBuilder>{},
Map<String, Widget Function(BuildContext)> this.routes = const <String, WidgetBuilder>{},
this.initialRoute,
this.onGenerateRoute,
this.onGenerateInitialRoutes,
this.onUnknownRoute,
this.navigatorObservers = const <NavigatorObserver>[],
List<NavigatorObserver> this.navigatorObservers = const <NavigatorObserver>[],
this.builder,
this.translationsKeys,
this.translations,
... ... @@ -72,64 +72,64 @@ class GetCupertinoApp extends StatelessWidget {
backButtonDispatcher = null,
super(key: key);
final GlobalKey<NavigatorState> navigatorKey;
final Widget home;
final Map<String, WidgetBuilder> routes;
final String initialRoute;
final RouteFactory onGenerateRoute;
final InitialRouteListFactory onGenerateInitialRoutes;
final RouteFactory onUnknownRoute;
final List<NavigatorObserver> navigatorObservers;
final TransitionBuilder builder;
final GlobalKey<NavigatorState>? navigatorKey;
final Widget? home;
final Map<String, WidgetBuilder>? routes;
final String? initialRoute;
final RouteFactory? onGenerateRoute;
final InitialRouteListFactory? onGenerateInitialRoutes;
final RouteFactory? onUnknownRoute;
final List<NavigatorObserver>? navigatorObservers;
final TransitionBuilder? builder;
final String title;
final GenerateAppTitle onGenerateTitle;
final CustomTransition customTransition;
final Color color;
final Map<String, Map<String, String>> translationsKeys;
final Translations translations;
final TextDirection textDirection;
final Locale locale;
final Locale fallbackLocale;
final Iterable<LocalizationsDelegate<dynamic>> localizationsDelegates;
final LocaleListResolutionCallback localeListResolutionCallback;
final LocaleResolutionCallback localeResolutionCallback;
final GenerateAppTitle? onGenerateTitle;
final CustomTransition? customTransition;
final Color? color;
final Map<String, Map<String, String>>? translationsKeys;
final Translations? translations;
final TextDirection? textDirection;
final Locale? locale;
final Locale? fallbackLocale;
final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates;
final LocaleListResolutionCallback? localeListResolutionCallback;
final LocaleResolutionCallback? localeResolutionCallback;
final Iterable<Locale> supportedLocales;
final bool showPerformanceOverlay;
final bool checkerboardRasterCacheImages;
final bool checkerboardOffscreenLayers;
final bool showSemanticsDebugger;
final bool debugShowCheckedModeBanner;
final Map<LogicalKeySet, Intent> shortcuts;
final ThemeData highContrastTheme;
final ThemeData highContrastDarkTheme;
final Map<Type, Action<Intent>> actions;
final Function(Routing) routingCallback;
final Transition defaultTransition;
final bool opaqueRoute;
final VoidCallback onInit;
final VoidCallback onReady;
final VoidCallback onDispose;
final bool enableLog;
final LogWriterCallback logWriterCallback;
final bool popGesture;
final Map<LogicalKeySet, Intent>? shortcuts;
final ThemeData? highContrastTheme;
final ThemeData? highContrastDarkTheme;
final Map<Type, Action<Intent>>? actions;
final Function(Routing)? routingCallback;
final Transition? defaultTransition;
final bool? opaqueRoute;
final VoidCallback? onInit;
final VoidCallback? onReady;
final VoidCallback? onDispose;
final bool? enableLog;
final LogWriterCallback? logWriterCallback;
final bool? popGesture;
final SmartManagement smartManagement;
final Bindings initialBinding;
final Duration transitionDuration;
final bool defaultGlobalState;
final List<GetPage> getPages;
final GetPage unknownRoute;
final RouteInformationProvider routeInformationProvider;
final RouteInformationParser<Object> routeInformationParser;
final RouterDelegate<Object> routerDelegate;
final BackButtonDispatcher backButtonDispatcher;
final CupertinoThemeData theme;
final Bindings? initialBinding;
final Duration? transitionDuration;
final bool? defaultGlobalState;
final List<GetPage>? getPages;
final GetPage? unknownRoute;
final RouteInformationProvider? routeInformationProvider;
final RouteInformationParser<Object>? routeInformationParser;
final RouterDelegate<Object>? routerDelegate;
final BackButtonDispatcher? backButtonDispatcher;
final CupertinoThemeData? theme;
const GetCupertinoApp.router({
Key key,
Key? key,
this.theme,
this.routeInformationProvider,
@required this.routeInformationParser,
@required this.routerDelegate,
required RouteInformationParser<Object> this.routeInformationParser,
required RouterDelegate<Object> this.routerDelegate,
this.backButtonDispatcher,
this.builder,
this.title = '',
... ... @@ -201,7 +201,7 @@ class GetCupertinoApp extends StatelessWidget {
onDispose?.call();
},
initState: (i) {
Get.engine.addPostFrameCallback((timeStamp) {
Get.engine!.addPostFrameCallback((timeStamp) {
onReady?.call();
});
if (locale != null) Get.locale = locale;
... ... @@ -209,9 +209,9 @@ class GetCupertinoApp extends StatelessWidget {
if (fallbackLocale != null) Get.fallbackLocale = fallbackLocale;
if (translations != null) {
Get.addTranslations(translations.keys);
Get.addTranslations(translations!.keys);
} else if (translationsKeys != null) {
Get.addTranslations(translationsKeys);
Get.addTranslations(translationsKeys!);
}
Get.customTransition = customTransition;
... ... @@ -233,8 +233,8 @@ class GetCupertinoApp extends StatelessWidget {
},
builder: (_) => routerDelegate != null
? CupertinoApp.router(
routerDelegate: routerDelegate,
routeInformationParser: routeInformationParser,
routerDelegate: routerDelegate!,
routeInformationParser: routeInformationParser!,
backButtonDispatcher: backButtonDispatcher,
routeInformationProvider: routeInformationProvider,
key: _.unikey,
... ... @@ -245,7 +245,7 @@ class GetCupertinoApp extends StatelessWidget {
(rtlLanguages.contains(Get.locale?.languageCode)
? TextDirection.rtl
: TextDirection.ltr),
child: builder == null ? child : builder(context, child),
child: builder == null ? child! : builder!(context, child),
);
},
title: title ?? '',
... ... @@ -285,14 +285,14 @@ class GetCupertinoApp extends StatelessWidget {
: <NavigatorObserver>[
GetObserver(routingCallback, Get.routing)
]
..addAll(navigatorObservers)),
..addAll(navigatorObservers!)),
builder: (context, child) {
return Directionality(
textDirection: textDirection ??
(rtlLanguages.contains(Get.locale?.languageCode)
? TextDirection.rtl
: TextDirection.ltr),
child: builder == null ? child : builder(context, child),
child: builder == null ? child! : builder!(context, child),
);
},
title: title ?? '',
... ...
... ... @@ -10,15 +10,15 @@ import 'root_controller.dart';
class GetMaterialApp extends StatelessWidget {
const GetMaterialApp({
Key key,
Key? key,
this.navigatorKey,
this.home,
this.routes = const <String, WidgetBuilder>{},
Map<String, Widget Function(BuildContext)> this.routes = const <String, WidgetBuilder>{},
this.initialRoute,
this.onGenerateRoute,
this.onGenerateInitialRoutes,
this.onUnknownRoute,
this.navigatorObservers = const <NavigatorObserver>[],
List<NavigatorObserver> this.navigatorObservers = const <NavigatorObserver>[],
this.builder,
this.textDirection,
this.title = '',
... ... @@ -76,66 +76,66 @@ class GetMaterialApp extends StatelessWidget {
backButtonDispatcher = null,
super(key: key);
final GlobalKey<NavigatorState> navigatorKey;
final Widget home;
final Map<String, WidgetBuilder> routes;
final String initialRoute;
final RouteFactory onGenerateRoute;
final InitialRouteListFactory onGenerateInitialRoutes;
final RouteFactory onUnknownRoute;
final List<NavigatorObserver> navigatorObservers;
final TransitionBuilder builder;
final GlobalKey<NavigatorState>? navigatorKey;
final Widget? home;
final Map<String, WidgetBuilder>? routes;
final String? initialRoute;
final RouteFactory? onGenerateRoute;
final InitialRouteListFactory? onGenerateInitialRoutes;
final RouteFactory? onUnknownRoute;
final List<NavigatorObserver>? navigatorObservers;
final TransitionBuilder? builder;
final String title;
final GenerateAppTitle onGenerateTitle;
final ThemeData theme;
final ThemeData darkTheme;
final GenerateAppTitle? onGenerateTitle;
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;
final TextDirection textDirection;
final Locale locale;
final Locale fallbackLocale;
final Iterable<LocalizationsDelegate<dynamic>> localizationsDelegates;
final LocaleListResolutionCallback localeListResolutionCallback;
final LocaleResolutionCallback localeResolutionCallback;
final CustomTransition? customTransition;
final Color? color;
final Map<String, Map<String, String>>? translationsKeys;
final Translations? translations;
final TextDirection? textDirection;
final Locale? locale;
final Locale? fallbackLocale;
final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates;
final LocaleListResolutionCallback? localeListResolutionCallback;
final LocaleResolutionCallback? localeResolutionCallback;
final Iterable<Locale> supportedLocales;
final bool showPerformanceOverlay;
final bool checkerboardRasterCacheImages;
final bool checkerboardOffscreenLayers;
final bool showSemanticsDebugger;
final bool debugShowCheckedModeBanner;
final Map<LogicalKeySet, Intent> shortcuts;
final ThemeData highContrastTheme;
final ThemeData highContrastDarkTheme;
final Map<Type, Action<Intent>> actions;
final Map<LogicalKeySet, Intent>? shortcuts;
final ThemeData? highContrastTheme;
final ThemeData? highContrastDarkTheme;
final Map<Type, Action<Intent>>? actions;
final bool debugShowMaterialGrid;
final ValueChanged<Routing> routingCallback;
final Transition defaultTransition;
final bool opaqueRoute;
final VoidCallback onInit;
final VoidCallback onReady;
final VoidCallback onDispose;
final bool enableLog;
final LogWriterCallback logWriterCallback;
final bool popGesture;
final ValueChanged<Routing>? routingCallback;
final Transition? defaultTransition;
final bool? opaqueRoute;
final VoidCallback? onInit;
final VoidCallback? onReady;
final VoidCallback? onDispose;
final bool? enableLog;
final LogWriterCallback? logWriterCallback;
final bool? popGesture;
final SmartManagement smartManagement;
final Bindings initialBinding;
final Duration transitionDuration;
final bool defaultGlobalState;
final List<GetPage> getPages;
final GetPage unknownRoute;
final RouteInformationProvider routeInformationProvider;
final RouteInformationParser<Object> routeInformationParser;
final RouterDelegate<Object> routerDelegate;
final BackButtonDispatcher backButtonDispatcher;
final Bindings? initialBinding;
final Duration? transitionDuration;
final bool? defaultGlobalState;
final List<GetPage>? getPages;
final GetPage? unknownRoute;
final RouteInformationProvider? routeInformationProvider;
final RouteInformationParser<Object>? routeInformationParser;
final RouterDelegate<Object>? routerDelegate;
final BackButtonDispatcher? backButtonDispatcher;
const GetMaterialApp.router({
Key key,
Key? key,
this.routeInformationProvider,
@required this.routeInformationParser,
@required this.routerDelegate,
required RouteInformationParser<Object> this.routeInformationParser,
required RouterDelegate<Object> this.routerDelegate,
this.backButtonDispatcher,
this.builder,
this.title = '',
... ... @@ -211,7 +211,7 @@ class GetMaterialApp extends StatelessWidget {
onDispose?.call();
},
initState: (i) {
Get.engine.addPostFrameCallback((timeStamp) {
Get.engine!.addPostFrameCallback((timeStamp) {
onReady?.call();
});
if (locale != null) Get.locale = locale;
... ... @@ -219,9 +219,9 @@ class GetMaterialApp extends StatelessWidget {
if (fallbackLocale != null) Get.fallbackLocale = fallbackLocale;
if (translations != null) {
Get.addTranslations(translations.keys);
Get.addTranslations(translations!.keys);
} else if (translationsKeys != null) {
Get.addTranslations(translationsKeys);
Get.addTranslations(translationsKeys!);
}
Get.customTransition = customTransition;
... ... @@ -243,8 +243,8 @@ class GetMaterialApp extends StatelessWidget {
},
builder: (_) => routerDelegate != null
? MaterialApp.router(
routerDelegate: routerDelegate,
routeInformationParser: routeInformationParser,
routerDelegate: routerDelegate!,
routeInformationParser: routeInformationParser!,
backButtonDispatcher: backButtonDispatcher,
routeInformationProvider: routeInformationProvider,
key: _.unikey,
... ... @@ -254,7 +254,7 @@ class GetMaterialApp extends StatelessWidget {
(rtlLanguages.contains(Get.locale?.languageCode)
? TextDirection.rtl
: TextDirection.ltr),
child: builder == null ? child : builder(context, child),
child: builder == null ? child! : builder!(context, child),
);
},
title: title ?? '',
... ... @@ -297,14 +297,14 @@ class GetMaterialApp extends StatelessWidget {
: <NavigatorObserver>[
GetObserver(routingCallback, Get.routing)
]
..addAll(navigatorObservers)),
..addAll(navigatorObservers!)),
builder: (context, child) {
return Directionality(
textDirection: textDirection ??
(rtlLanguages.contains(Get.locale?.languageCode)
? TextDirection.rtl
: TextDirection.ltr),
child: builder == null ? child : builder(context, child),
child: builder == null ? child! : builder!(context, child),
);
},
title: title ?? '',
... ...
... ... @@ -2,10 +2,11 @@ import '../../../get_core/src/get_main.dart';
import '../../get_navigation.dart';
import '../routes/get_route.dart';
import 'package:collection/collection.dart' show IterableExtension;
class RouteDecoder {
final GetPage route;
final Map<String, String> parameters;
final GetPage? route;
final Map<String?, String> parameters;
const RouteDecoder(this.route, this.parameters);
}
... ... @@ -15,7 +16,7 @@ class ParseRouteTree {
RouteDecoder matchRoute(String name) {
final uri = Uri.parse(name);
final route = _findRoute(uri.path);
final params = Map<String, String>.from(uri.queryParameters);
final params = Map<String?, String>.from(uri.queryParameters);
if (route != null) {
final parsedParams = _parseParams(name, route.path);
if (parsedParams != null && parsedParams.isNotEmpty) {
... ... @@ -45,12 +46,12 @@ class ParseRouteTree {
List<GetPage> _flattenPage(GetPage route) {
final result = <GetPage>[];
if (route.children == null || route.children.isEmpty) {
if (route.children == null || route.children!.isEmpty) {
return result;
}
final parentPath = route.name;
for (var page in route.children) {
for (var page in route.children!) {
// Add Parent middlewares to children
final pageMiddlewares = page.middlewares ?? <GetMiddleware>[];
pageMiddlewares.addAll(route.middlewares ?? <GetMiddleware>[]);
... ... @@ -88,19 +89,18 @@ class ParseRouteTree {
middlewares: middlewares,
);
GetPage _findRoute(String name) {
return _routes.firstWhere(
GetPage? _findRoute(String name) {
return _routes.firstWhereOrNull(
(route) => route.path.regex.hasMatch(name),
orElse: () => null,
);
}
Map<String, String> _parseParams(String path, PathDecoded routePath) {
final params = <String, String>{};
Match paramsMatch = routePath.regex.firstMatch(path);
Map<String?, String> _parseParams(String path, PathDecoded routePath) {
final params = <String?, String>{};
Match? paramsMatch = routePath.regex.firstMatch(path);
for (var i = 0; i < routePath.keys.length; i++) {
var param = Uri.decodeQueryComponent(paramsMatch[i + 1]);
var param = Uri.decodeQueryComponent(paramsMatch![i + 1]!);
params[routePath.keys[i]] = param;
}
return params;
... ...
... ... @@ -8,14 +8,14 @@ import 'parse_route.dart';
class GetMaterialController extends GetxController {
bool testMode = false;
Key unikey;
ThemeData theme;
ThemeMode themeMode;
Key? unikey;
ThemeData? theme;
ThemeMode? themeMode;
bool defaultPopGesture = GetPlatform.isIOS;
bool defaultOpaqueRoute = true;
Transition defaultTransition;
Transition? defaultTransition;
Duration defaultTransitionDuration = Duration(milliseconds: 300);
Curve defaultTransitionCurve = Curves.easeOutQuad;
... ... @@ -25,13 +25,13 @@ class GetMaterialController extends GetxController {
final routing = Routing();
Map<String, String> parameters = {};
Map<String?, String> parameters = {};
ParseRouteTree routeTree;
ParseRouteTree? routeTree;
CustomTransition customTransition;
CustomTransition? customTransition;
GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>();
GlobalKey<NavigatorState>? key = GlobalKey<NavigatorState>();
Map<int, GlobalKey<NavigatorState>> keys = {};
... ...
... ... @@ -4,8 +4,8 @@ import 'package:flutter/widgets.dart';
abstract class CustomTransition {
Widget buildTransition(
BuildContext context,
Curve curve,
Alignment alignment,
Curve? curve,
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
... ...
... ... @@ -12,7 +12,7 @@ import 'transitions_type.dart';
class GetPageRoute<T> extends PageRoute<T> {
GetPageRoute({
RouteSettings settings,
RouteSettings? settings,
this.transitionDuration = const Duration(milliseconds: 300),
this.opaque = true,
this.parameter,
... ... @@ -41,41 +41,41 @@ class GetPageRoute<T> extends PageRoute<T> {
@override
final Duration transitionDuration;
final GetPageBuilder page;
final GetPageBuilder? page;
final String routeName;
final String? routeName;
final String reference;
final CustomTransition customTransition;
final CustomTransition? customTransition;
final Bindings binding;
final Bindings? binding;
final Map<String, String> parameter;
final Map<String, String>? parameter;
final List<Bindings> bindings;
final List<Bindings>? bindings;
@override
final bool opaque;
final bool popGesture;
final bool? popGesture;
@override
final bool barrierDismissible;
final Transition transition;
final Transition? transition;
final Curve curve;
final Curve? curve;
final Alignment alignment;
final Alignment? alignment;
final List<GetMiddleware> middlewares;
final List<GetMiddleware>? middlewares;
@override
final Color barrierColor;
final Color? barrierColor;
@override
final String barrierLabel;
final String? barrierLabel;
@override
final bool maintainState;
... ... @@ -93,8 +93,8 @@ class GetPageRoute<T> extends PageRoute<T> {
route.willHandlePopInternally ||
route.hasScopedWillPopCallback ||
route.fullscreenDialog ||
route.animation.status != AnimationStatus.completed ||
route.secondaryAnimation.status != AnimationStatus.dismissed ||
route.animation!.status != AnimationStatus.completed ||
route.secondaryAnimation!.status != AnimationStatus.dismissed ||
isPopGestureInProgress(route)) return false;
return true;
... ... @@ -105,8 +105,8 @@ class GetPageRoute<T> extends PageRoute<T> {
assert(_isPopGestureEnabled(route));
return _CupertinoBackGestureController<T>(
navigator: route.navigator,
controller: route.controller,
navigator: route.navigator!,
controller: route.controller!,
);
}
... ... @@ -129,12 +129,12 @@ class GetPageRoute<T> extends PageRoute<T> {
}
}
final pageToBuild = middlewareRunner.runOnPageBuildStart(page);
final pageToBuild = middlewareRunner.runOnPageBuildStart(page)!;
return middlewareRunner.runOnPageBuilt(pageToBuild());
}
static bool isPopGestureInProgress(PageRoute<dynamic> route) {
return route.navigator.userGestureInProgress;
return route.navigator!.userGestureInProgress;
}
bool get popGestureInProgress => isPopGestureInProgress(this);
... ... @@ -156,7 +156,7 @@ class GetPageRoute<T> extends PageRoute<T> {
linearTransition: hasCurve);
}
if (customTransition != null) {
return customTransition.buildTransition(
return customTransition!.buildTransition(
context,
finalCurve,
alignment,
... ... @@ -312,7 +312,7 @@ class GetPageRoute<T> extends PageRoute<T> {
case Transition.size:
return SizeTransitions().buildTransitions(
context,
curve,
curve!,
alignment,
animation,
secondaryAnimation,
... ... @@ -364,7 +364,7 @@ class GetPageRoute<T> extends PageRoute<T> {
default:
if (Get.customTransition != null) {
return Get.customTransition.buildTransition(
return Get.customTransition!.buildTransition(
context, curve, alignment, animation, secondaryAnimation, child);
}
... ... @@ -386,7 +386,7 @@ class GetPageRoute<T> extends PageRoute<T> {
void dispose() {
super.dispose();
if (Get.smartManagement != SmartManagement.onlyBuilder) {
WidgetsBinding.instance.addPostFrameCallback((_) {
WidgetsBinding.instance!.addPostFrameCallback((_) {
if (Get.reference != reference) {
GetInstance().removeDependencyByRoute("$reference");
}
... ... @@ -412,10 +412,10 @@ const int _kMaxPageBackAnimationTime = 300;
class _CupertinoBackGestureDetector<T> extends StatefulWidget {
const _CupertinoBackGestureDetector({
Key key,
@required this.enabledCallback,
@required this.onStartPopGesture,
@required this.child,
Key? key,
required this.enabledCallback,
required this.onStartPopGesture,
required this.child,
}) : assert(enabledCallback != null),
assert(onStartPopGesture != null),
assert(child != null),
... ... @@ -434,9 +434,9 @@ class _CupertinoBackGestureDetector<T> extends StatefulWidget {
class _CupertinoBackGestureDetectorState<T>
extends State<_CupertinoBackGestureDetector<T>> {
_CupertinoBackGestureController<T> _backGestureController;
_CupertinoBackGestureController<T>? _backGestureController;
HorizontalDragGestureRecognizer _recognizer;
late HorizontalDragGestureRecognizer _recognizer;
@override
void initState() {
... ... @@ -463,15 +463,15 @@ class _CupertinoBackGestureDetectorState<T>
void _handleDragUpdate(DragUpdateDetails details) {
assert(mounted);
assert(_backGestureController != null);
_backGestureController.dragUpdate(
_convertToLogical(details.primaryDelta / context.size.width));
_backGestureController!.dragUpdate(
_convertToLogical(details.primaryDelta! / context.size!.width)!);
}
void _handleDragEnd(DragEndDetails details) {
assert(mounted);
assert(_backGestureController != null);
_backGestureController.dragEnd(_convertToLogical(
details.velocity.pixelsPerSecond.dx / context.size.width));
_backGestureController!.dragEnd(_convertToLogical(
details.velocity.pixelsPerSecond.dx / context.size!.width)!);
_backGestureController = null;
}
... ... @@ -487,7 +487,7 @@ class _CupertinoBackGestureDetectorState<T>
if (widget.enabledCallback()) _recognizer.addPointer(event);
}
double _convertToLogical(double value) {
double? _convertToLogical(double value) {
switch (Directionality.of(context)) {
case TextDirection.rtl:
return -value;
... ... @@ -533,8 +533,8 @@ class _CupertinoBackGestureController<T> {
///
/// The [navigator] and [controller] arguments must not be null.
_CupertinoBackGestureController({
@required this.navigator,
@required this.controller,
required this.navigator,
required this.controller,
}) : assert(navigator != null),
assert(controller != null) {
navigator.didStartUserGesture();
... ... @@ -579,7 +579,7 @@ class _CupertinoBackGestureController<T> {
_kMaxDroppedSwipePageForwardAnimationTime,
0,
controller.value,
).floor(),
)!.floor(),
_kMaxPageBackAnimationTime,
);
controller.animateTo(1.0,
... ... @@ -597,7 +597,7 @@ class _CupertinoBackGestureController<T> {
0,
_kMaxDroppedSwipePageForwardAnimationTime,
controller.value,
).floor();
)!.floor();
controller.animateBack(
0.0,
duration: Duration(milliseconds: droppedPageBackAnimationTime),
... ... @@ -610,7 +610,7 @@ class _CupertinoBackGestureController<T> {
// Keep the userGestureInProgress in true state so we don't change the
// curve of the page transition mid-flight since CupertinoPageTransition
// depends on userGestureInProgress.
AnimationStatusListener animationStatusCallback;
late AnimationStatusListener animationStatusCallback;
animationStatusCallback = (status) {
navigator.didStopUserGesture();
controller.removeStatusListener(animationStatusCallback);
... ...
... ... @@ -4,8 +4,8 @@ import 'package:flutter/material.dart';
class LeftToRightFadeTransition {
Widget buildTransitions(
BuildContext context,
Curve curve,
Alignment alignment,
Curve? curve,
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
... ... @@ -30,8 +30,8 @@ class LeftToRightFadeTransition {
class RightToLeftFadeTransition {
Widget buildTransitions(
BuildContext context,
Curve curve,
Alignment alignment,
Curve? curve,
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
... ... @@ -68,8 +68,8 @@ class NoTransition {
class FadeInTransition {
Widget buildTransitions(
BuildContext context,
Curve curve,
Alignment alignment,
Curve? curve,
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
... ... @@ -80,8 +80,8 @@ class FadeInTransition {
class SlideDownTransition {
Widget buildTransitions(
BuildContext context,
Curve curve,
Alignment alignment,
Curve? curve,
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
... ... @@ -98,8 +98,8 @@ class SlideDownTransition {
class SlideLeftTransition {
Widget buildTransitions(
BuildContext context,
Curve curve,
Alignment alignment,
Curve? curve,
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
... ... @@ -116,8 +116,8 @@ class SlideLeftTransition {
class SlideRightTransition {
Widget buildTransitions(
BuildContext context,
Curve curve,
Alignment alignment,
Curve? curve,
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
... ... @@ -134,8 +134,8 @@ class SlideRightTransition {
class SlideTopTransition {
Widget buildTransitions(
BuildContext context,
Curve curve,
Alignment alignment,
Curve? curve,
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
... ... @@ -152,8 +152,8 @@ class SlideTopTransition {
class ZoomInTransition {
Widget buildTransitions(
BuildContext context,
Curve curve,
Alignment alignment,
Curve? curve,
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
... ... @@ -168,7 +168,7 @@ class SizeTransitions {
Widget buildTransitions(
BuildContext context,
Curve curve,
Alignment alignment,
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
... ...
... ... @@ -8,33 +8,33 @@ import 'transitions_type.dart';
class PathDecoded {
const PathDecoded(this.regex, this.keys);
final RegExp regex;
final List<String> keys;
final List<String?> keys;
}
class GetPage {
final String name;
final GetPageBuilder page;
final bool popGesture;
final Map<String, String> parameter;
final String title;
final Transition transition;
final bool? popGesture;
final Map<String, String>? parameter;
final String? title;
final Transition? transition;
final Curve curve;
final Alignment alignment;
final Alignment? alignment;
final bool maintainState;
final bool opaque;
final Bindings binding;
final Bindings? binding;
final List<Bindings> bindings;
final CustomTransition customTransition;
final Duration transitionDuration;
final CustomTransition? customTransition;
final Duration? transitionDuration;
final bool fullscreenDialog;
final RouteSettings settings;
final List<GetPage> children;
final List<GetMiddleware> middlewares;
final RouteSettings? settings;
final List<GetPage>? children;
final List<GetMiddleware>? middlewares;
final PathDecoded path;
GetPage({
@required this.name,
@required this.page,
required this.name,
required this.page,
this.title,
this.settings,
this.maintainState = true,
... ... @@ -58,7 +58,7 @@ class GetPage {
assert(fullscreenDialog != null);
static PathDecoded _nameToRegex(String path) {
var keys = <String>[];
var keys = <String?>[];
String _replace(Match pattern) {
var buffer = StringBuffer('(?:');
... ... @@ -79,24 +79,24 @@ class GetPage {
}
GetPage copyWith({
String name,
GetPageBuilder page,
bool popGesture,
Map<String, String> parameter,
String title,
Transition transition,
Curve curve,
Alignment alignment,
bool maintainState,
bool opaque,
Bindings binding,
List<Bindings> bindings,
CustomTransition customTransition,
Duration transitionDuration,
bool fullscreenDialog,
RouteSettings settings,
List<GetPage> children,
List<GetMiddleware> middlewares,
String? name,
GetPageBuilder? page,
bool? popGesture,
Map<String, String>? parameter,
String? title,
Transition? transition,
Curve? curve,
Alignment? alignment,
bool? maintainState,
bool? opaque,
Bindings? binding,
List<Bindings>? bindings,
CustomTransition? customTransition,
Duration? transitionDuration,
bool? fullscreenDialog,
RouteSettings? settings,
List<GetPage>? children,
List<GetMiddleware>? middlewares,
}) {
return GetPage(
name: name ?? this.name,
... ...
... ... @@ -10,11 +10,11 @@ class Routing {
String previous;
dynamic args;
String removed;
Route<dynamic> route;
bool isBack;
bool isSnackbar;
bool isBottomSheet;
bool isDialog;
Route<dynamic>? route;
bool? isBack;
bool? isSnackbar;
bool? isBottomSheet;
bool? isDialog;
Routing({
this.current = '',
... ... @@ -35,9 +35,9 @@ class Routing {
/// Extracts the name of a route based on it's instance type
/// or null if not possible.
String _extractRouteName(Route route) {
String? _extractRouteName(Route? route) {
if (route?.settings?.name != null) {
return route.settings.name;
return route!.settings.name;
}
if (route is GetPageRoute) {
... ... @@ -61,17 +61,17 @@ class _RouteData {
final bool isSnackbar;
final bool isBottomSheet;
final bool isDialog;
final String name;
final String? name;
_RouteData({
@required this.name,
@required this.isGetPageRoute,
@required this.isSnackbar,
@required this.isBottomSheet,
@required this.isDialog,
required this.name,
required this.isGetPageRoute,
required this.isSnackbar,
required this.isBottomSheet,
required this.isDialog,
});
factory _RouteData.ofRoute(Route route) {
factory _RouteData.ofRoute(Route? route) {
return _RouteData(
name: _extractRouteName(route),
isGetPageRoute: route is GetPageRoute,
... ... @@ -83,14 +83,14 @@ class _RouteData {
}
class GetObserver extends NavigatorObserver {
final Function(Routing) routing;
final Function(Routing?)? routing;
GetObserver([this.routing, this._routeSend]);
final Routing _routeSend;
final Routing? _routeSend;
@override
void didPush(Route route, Route previousRoute) {
void didPush(Route route, Route? previousRoute) {
super.didPush(route, previousRoute);
final newRoute = _RouteData.ofRoute(route);
... ... @@ -122,12 +122,12 @@ class GetObserver extends NavigatorObserver {
});
if (routing != null) {
routing(_routeSend);
routing!(_routeSend);
}
}
@override
void didPop(Route route, Route previousRoute) {
void didPop(Route route, Route? previousRoute) {
super.didPop(route, previousRoute);
final currentRoute = _RouteData.ofRoute(route);
final newRoute = _RouteData.ofRoute(previousRoute);
... ... @@ -167,7 +167,7 @@ class GetObserver extends NavigatorObserver {
}
@override
void didReplace({Route newRoute, Route oldRoute}) {
void didReplace({Route? newRoute, Route? oldRoute}) {
super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
final newName = _extractRouteName(newRoute);
final oldName = _extractRouteName(oldRoute);
... ... @@ -198,7 +198,7 @@ class GetObserver extends NavigatorObserver {
}
@override
void didRemove(Route route, Route previousRoute) {
void didRemove(Route route, Route? previousRoute) {
super.didRemove(route, previousRoute);
final routeName = _extractRouteName(route);
final currentRoute = _RouteData.ofRoute(route);
... ...
... ... @@ -16,7 +16,7 @@ abstract class _RouteMiddleware {
/// ```
/// -8 => 2 => 4 => 5
/// {@end-tool}
int priority;
int? priority;
/// This function will be called when the page of
/// the called route is being searched for.
... ... @@ -30,7 +30,7 @@ abstract class _RouteMiddleware {
/// }
/// ```
/// {@end-tool}
RouteSettings redirect(String route);
RouteSettings? redirect(String route);
/// This function will be called when this Page is called
/// you can use it to change something about the page or give it new page
... ... @@ -42,7 +42,7 @@ abstract class _RouteMiddleware {
/// }
/// ```
/// {@end-tool}
GetPage onPageCalled(GetPage page);
GetPage? onPageCalled(GetPage page);
/// This function will be called right before the [Bindings] are initialize.
/// Here you can change [Bindings] for this page
... ... @@ -57,10 +57,10 @@ abstract class _RouteMiddleware {
/// }
/// ```
/// {@end-tool}
List<Bindings> onBindingsStart(List<Bindings> bindings);
List<Bindings>? onBindingsStart(List<Bindings> bindings);
/// This function will be called right after the [Bindings] are initialize.
GetPageBuilder onPageBuildStart(GetPageBuilder page);
GetPageBuilder? onPageBuildStart(GetPageBuilder page);
/// This function will be called right after the
/// GetPage.page function is called and will give you the result
... ... @@ -76,21 +76,21 @@ abstract class _RouteMiddleware {
/// [onPageBuildStart] -> [onPageBuilt] -> [onPageDispose] ))
class GetMiddleware implements _RouteMiddleware {
@override
int priority = 0;
int? priority = 0;
GetMiddleware({this.priority});
@override
RouteSettings redirect(String route) => null;
RouteSettings? redirect(String? route) => null;
@override
GetPage onPageCalled(GetPage page) => page;
GetPage? onPageCalled(GetPage? page) => page;
@override
List<Bindings> onBindingsStart(List<Bindings> bindings) => bindings;
List<Bindings>? onBindingsStart(List<Bindings>? bindings) => bindings;
@override
GetPageBuilder onPageBuildStart(GetPageBuilder page) => page;
GetPageBuilder? onPageBuildStart(GetPageBuilder? page) => page;
@override
Widget onPageBuilt(Widget page) => page;
... ... @@ -102,26 +102,26 @@ class GetMiddleware implements _RouteMiddleware {
class MiddlewareRunner {
MiddlewareRunner(this._middlewares);
final List<GetMiddleware> _middlewares;
final List<GetMiddleware>? _middlewares;
List<GetMiddleware> _getMiddlewares() {
List<GetMiddleware>? _getMiddlewares() {
if (_middlewares != null) {
_middlewares.sort((a, b) => a.priority.compareTo(b.priority));
_middlewares!.sort((a, b) => a.priority!.compareTo(b.priority!));
return _middlewares;
}
return <GetMiddleware>[];
}
GetPage runOnPageCalled(GetPage page) {
_getMiddlewares().forEach((element) {
GetPage? runOnPageCalled(GetPage? page) {
_getMiddlewares()!.forEach((element) {
page = element.onPageCalled(page);
});
return page;
}
RouteSettings runRedirect(String route) {
RouteSettings to;
_getMiddlewares().forEach((element) {
RouteSettings? runRedirect(String? route) {
RouteSettings? to;
_getMiddlewares()!.forEach((element) {
to = element.redirect(route);
});
if (to != null) {
... ... @@ -130,34 +130,34 @@ class MiddlewareRunner {
return to;
}
List<Bindings> runOnBindingsStart(List<Bindings> bindings) {
_getMiddlewares().forEach((element) {
List<Bindings>? runOnBindingsStart(List<Bindings>? bindings) {
_getMiddlewares()!.forEach((element) {
bindings = element.onBindingsStart(bindings);
});
return bindings;
}
GetPageBuilder runOnPageBuildStart(GetPageBuilder page) {
_getMiddlewares().forEach((element) {
GetPageBuilder? runOnPageBuildStart(GetPageBuilder? page) {
_getMiddlewares()!.forEach((element) {
page = element.onPageBuildStart(page);
});
return page;
}
Widget runOnPageBuilt(Widget page) {
_getMiddlewares().forEach((element) {
_getMiddlewares()!.forEach((element) {
page = element.onPageBuilt(page);
});
return page;
}
void runOnPageDispose() =>
_getMiddlewares().forEach((element) => element.onPageDispose());
_getMiddlewares()!.forEach((element) => element.onPageDispose());
}
class PageRedirect {
GetPage route;
GetPage unknownRoute;
GetPage? route;
GetPage? unknownRoute;
RouteSettings settings;
bool isUnknown;
... ... @@ -169,43 +169,43 @@ class PageRedirect {
while (needRecheck()) {}
return isUnknown
? GetPageRoute(
page: unknownRoute.page,
parameter: unknownRoute.parameter,
page: unknownRoute!.page,
parameter: unknownRoute!.parameter,
settings: RouteSettings(
name: unknownRoute.name, arguments: settings.arguments),
curve: unknownRoute.curve,
opaque: unknownRoute.opaque,
customTransition: unknownRoute.customTransition,
binding: unknownRoute.binding,
bindings: unknownRoute.bindings,
transitionDuration: (unknownRoute.transitionDuration ??
name: unknownRoute!.name, arguments: settings.arguments),
curve: unknownRoute!.curve,
opaque: unknownRoute!.opaque,
customTransition: unknownRoute!.customTransition,
binding: unknownRoute!.binding,
bindings: unknownRoute!.bindings,
transitionDuration: (unknownRoute!.transitionDuration ??
Get.defaultTransitionDuration),
transition: unknownRoute.transition,
popGesture: unknownRoute.popGesture,
fullscreenDialog: unknownRoute.fullscreenDialog,
middlewares: unknownRoute.middlewares,
transition: unknownRoute!.transition,
popGesture: unknownRoute!.popGesture,
fullscreenDialog: unknownRoute!.fullscreenDialog,
middlewares: unknownRoute!.middlewares,
)
: GetPageRoute(
page: route.page,
parameter: route.parameter,
page: route!.page,
parameter: route!.parameter,
settings: RouteSettings(
name: settings.name, arguments: settings.arguments),
curve: route.curve,
opaque: route.opaque,
customTransition: route.customTransition,
binding: route.binding,
bindings: route.bindings,
curve: route!.curve,
opaque: route!.opaque,
customTransition: route!.customTransition,
binding: route!.binding,
bindings: route!.bindings,
transitionDuration:
(route.transitionDuration ?? Get.defaultTransitionDuration),
transition: route.transition,
popGesture: route.popGesture,
fullscreenDialog: route.fullscreenDialog,
middlewares: route.middlewares);
(route!.transitionDuration ?? Get.defaultTransitionDuration),
transition: route!.transition,
popGesture: route!.popGesture,
fullscreenDialog: route!.fullscreenDialog,
middlewares: route!.middlewares);
}
/// check if redirect is needed
bool needRecheck() {
final match = Get.routeTree.matchRoute(settings.name);
final match = Get.routeTree!.matchRoute(settings.name!);
Get.parameters = match?.parameters;
// No Match found
... ... @@ -214,12 +214,12 @@ class PageRedirect {
return false;
}
final runner = MiddlewareRunner(match.route.middlewares);
final runner = MiddlewareRunner(match.route!.middlewares);
route = runner.runOnPageCalled(match.route);
addPageParameter(route);
addPageParameter(route!);
// No middlewares found return match.
if (match.route.middlewares == null || match.route.middlewares.isEmpty) {
if (match.route!.middlewares == null || match.route!.middlewares!.isEmpty) {
return false;
}
final newSettings = runner.runRedirect(settings.name);
... ... @@ -234,10 +234,10 @@ class PageRedirect {
if (route.parameter == null) return;
if (Get.parameters == null) {
Get.parameters = route.parameter;
Get.parameters = route.parameter!;
} else {
final parameters = Get.parameters;
parameters.addEntries(route.parameter.entries);
parameters.addEntries(route.parameter!.entries);
Get.parameters = parameters;
}
}
... ...
... ... @@ -5,12 +5,12 @@ import 'package:flutter/scheduler.dart';
import '../../../get_core/get_core.dart';
import '../../get_navigation.dart';
typedef SnackbarStatusCallback = void Function(SnackbarStatus status);
typedef SnackbarStatusCallback = void Function(SnackbarStatus? status);
typedef OnTap = void Function(GetBar snack);
class GetBar<T extends Object> extends StatefulWidget {
GetBar({
Key key,
Key? key,
this.title,
this.message,
this.titleText,
... ... @@ -45,7 +45,7 @@ class GetBar<T extends Object> extends StatefulWidget {
this.overlayBlur = 0.0,
this.overlayColor = Colors.transparent,
this.userInputForm,
SnackbarStatusCallback snackbarStatus,
SnackbarStatusCallback? snackbarStatus,
}) : snackbarStatus = (snackbarStatus ?? (status) {}),
super(key: key);
... ... @@ -53,18 +53,18 @@ class GetBar<T extends Object> extends StatefulWidget {
final SnackbarStatusCallback snackbarStatus;
/// The title displayed to the user
final String title;
final String? title;
/// The message displayed to the user.
final String message;
final String? message;
/// Replaces [title]. Although this accepts a [Widget], it is meant
/// to receive [Text] or [RichText]
final Widget titleText;
final Widget? titleText;
/// Replaces [message]. Although this accepts a [Widget], it is meant
/// to receive [Text] or [RichText]
final Widget messageText;
final Widget? messageText;
/// Will be ignored if [backgroundGradient] is not null
final Color backgroundColor;
... ... @@ -72,48 +72,48 @@ class GetBar<T extends Object> extends StatefulWidget {
/// If not null, shows a left vertical colored bar on notification.
/// It is not possible to use it with a [Form] and I do not recommend
/// using it with [LinearProgressIndicator]
final Color leftBarIndicatorColor;
final Color? leftBarIndicatorColor;
/// [boxShadows] The shadows generated by Snack. Leave it null
/// if you don't want a shadow.
/// You can use more than one if you feel the need.
/// Check (this example)[https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/material/shadows.dart]
final List<BoxShadow> boxShadows;
final List<BoxShadow>? boxShadows;
/// Makes [backgroundColor] be ignored.
final Gradient backgroundGradient;
final Gradient? backgroundGradient;
/// You can use any widget here, but I recommend [Icon] or [Image] as
/// indication of what kind
/// of message you are displaying. Other widgets may break the layout
final Widget icon;
final Widget? icon;
/// An option to animate the icon (if present). Defaults to true.
final bool shouldIconPulse;
/// A [TextButton] widget if you need an action from the user.
final Widget mainButton;
final Widget? mainButton;
/// A callback that registers the user's click anywhere.
/// An alternative to [mainButton]
final OnTap onTap;
final OnTap? onTap;
/// How long until Snack will hide itself (be dismissed).
/// To make it indefinite, leave it null.
final Duration duration;
final Duration? duration;
/// True if you want to show a [LinearProgressIndicator].
final bool showProgressIndicator;
/// An optional [AnimationController] when you want to control the
/// progress of your [LinearProgressIndicator].
final AnimationController progressIndicatorController;
final AnimationController? progressIndicatorController;
/// A [LinearProgressIndicator] configuration parameter.
final Color progressIndicatorBackgroundColor;
final Color? progressIndicatorBackgroundColor;
/// A [LinearProgressIndicator] configuration parameter.
final Animation<Color> progressIndicatorValueColor;
final Animation<Color>? progressIndicatorValueColor;
/// Determines if the user can swipe or click the overlay
/// (if [overlayBlur] > 0) to dismiss.
... ... @@ -123,7 +123,7 @@ class GetBar<T extends Object> extends StatefulWidget {
final bool isDismissible;
/// Used to limit Snack width (usually on large screens)
final double maxWidth;
final double? maxWidth;
/// Adds a custom margin to Snack
final EdgeInsets margin;
... ... @@ -140,10 +140,10 @@ class GetBar<T extends Object> extends StatefulWidget {
/// Adds a border to every side of Snack
/// I do not recommend using it with [showProgressIndicator]
/// or [leftBarIndicatorColor].
final Color borderColor;
final Color? borderColor;
/// Changes the width of the border if [borderColor] is specified
final double borderWidth;
final double? borderWidth;
/// Snack can be based on [SnackPosition.TOP] or on [SnackPosition.BOTTOM]
/// of your screen.
... ... @@ -176,7 +176,7 @@ class GetBar<T extends Object> extends StatefulWidget {
/// Default is 0.0. If different than 0.0, blurs only Snack's background.
/// To take effect, make sure your [backgroundColor] has some opacity.
/// The greater the value, the greater the blur.
final double barBlur;
final double? barBlur;
/// Default is 0.0. If different than 0.0, creates a blurred
/// overlay that prevents the user from interacting with the screen.
... ... @@ -186,15 +186,15 @@ class GetBar<T extends Object> extends StatefulWidget {
/// Default is [Colors.transparent]. Only takes effect if [overlayBlur] > 0.0.
/// Make sure you use a color with transparency here e.g.
/// Colors.grey[600].withOpacity(0.2).
final Color overlayColor;
final Color? overlayColor;
/// A [TextFormField] in case you want a simple user input.
/// Every other widget is ignored if this is not null.
final Form userInputForm;
final Form? userInputForm;
/// Show the snack. It's call [SnackbarStatus.OPENING] state
/// followed by [SnackbarStatus.OPEN]
Future<T> show<T>() async {
Future<T?>? show<T>() async {
return Get.showSnackbar(this);
}
... ... @@ -206,10 +206,10 @@ class GetBar<T extends Object> extends StatefulWidget {
class _GetBarState<K extends Object> extends State<GetBar>
with TickerProviderStateMixin {
SnackbarStatus currentStatus;
SnackbarStatus? currentStatus;
AnimationController _fadeController;
Animation<double> _fadeAnimation;
AnimationController? _fadeController;
late Animation<double> _fadeAnimation;
final Widget _emptyWidget = SizedBox(width: 0.0, height: 0.0);
final double _initialOpacity = 1.0;
... ... @@ -217,20 +217,20 @@ class _GetBarState<K extends Object> extends State<GetBar>
final Duration _pulseAnimationDuration = Duration(seconds: 1);
bool _isTitlePresent;
double _messageTopMargin;
late bool _isTitlePresent;
late double _messageTopMargin;
FocusScopeNode _focusNode;
FocusAttachment _focusAttachment;
FocusScopeNode? _focusNode;
late FocusAttachment _focusAttachment;
@override
void initState() {
super.initState();
assert(
((widget.userInputForm != null ||
((widget.message != null && widget.message.isNotEmpty) ||
widget.messageText != null))),
widget.userInputForm != null ||
((widget.message != null && widget.message!.isNotEmpty) ||
widget.messageText != null),
"""
A message is mandatory if you are not using userInputForm.
Set either a message or messageText""");
... ... @@ -247,7 +247,7 @@ Set either a message or messageText""");
}
_focusNode = FocusScopeNode();
_focusAttachment = _focusNode.attach(context);
_focusAttachment = _focusNode!.attach(context);
}
@override
... ... @@ -258,14 +258,14 @@ Set either a message or messageText""");
widget.progressIndicatorController?.dispose();
_focusAttachment.detach();
_focusNode.dispose();
_focusNode!.dispose();
super.dispose();
}
final Completer<Size> _boxHeightCompleter = Completer<Size>();
void _configureLeftBarFuture() {
SchedulerBinding.instance.addPostFrameCallback(
SchedulerBinding.instance!.addPostFrameCallback(
(_) {
final keyContext = backgroundBoxKey.currentContext;
... ... @@ -282,24 +282,24 @@ Set either a message or messageText""");
AnimationController(vsync: this, duration: _pulseAnimationDuration);
_fadeAnimation = Tween(begin: _initialOpacity, end: _finalOpacity).animate(
CurvedAnimation(
parent: _fadeController,
parent: _fadeController!,
curve: Curves.linear,
),
);
_fadeController.addStatusListener((status) {
_fadeController!.addStatusListener((status) {
if (status == AnimationStatus.completed) {
_fadeController.reverse();
_fadeController!.reverse();
}
if (status == AnimationStatus.dismissed) {
_fadeController.forward();
_fadeController!.forward();
}
});
_fadeController.forward();
_fadeController!.forward();
}
VoidCallback _progressListener;
late VoidCallback _progressListener;
void _configureProgressIndicatorAnimation() {
if (widget.showProgressIndicator &&
... ... @@ -307,10 +307,10 @@ Set either a message or messageText""");
_progressListener = () {
setState(() {});
};
widget.progressIndicatorController.addListener(_progressListener);
widget.progressIndicatorController!.addListener(_progressListener);
_progressAnimation = CurvedAnimation(
curve: Curves.linear, parent: widget.progressIndicatorController);
curve: Curves.linear, parent: widget.progressIndicatorController!);
}
}
... ... @@ -361,10 +361,10 @@ Set either a message or messageText""");
borderRadius: BorderRadius.circular(widget.borderRadius),
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: widget.barBlur, sigmaY: widget.barBlur),
sigmaX: widget.barBlur!, sigmaY: widget.barBlur!),
child: Container(
height: snapshot.data.height,
width: snapshot.data.width,
height: snapshot.data!.height,
width: snapshot.data!.width,
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(widget.borderRadius),
... ... @@ -386,7 +386,7 @@ Set either a message or messageText""");
return Container(
key: backgroundBoxKey,
constraints: widget.maxWidth != null
? BoxConstraints(maxWidth: widget.maxWidth)
? BoxConstraints(maxWidth: widget.maxWidth!)
: null,
decoration: BoxDecoration(
color: widget.backgroundColor,
... ... @@ -394,14 +394,14 @@ Set either a message or messageText""");
boxShadow: widget.boxShadows,
borderRadius: BorderRadius.circular(widget.borderRadius),
border: widget.borderColor != null
? Border.all(color: widget.borderColor, width: widget.borderWidth)
? Border.all(color: widget.borderColor!, width: widget.borderWidth!)
: null,
),
child: Padding(
padding: const EdgeInsets.only(
left: 8.0, right: 8.0, bottom: 8.0, top: 16.0),
child: FocusScope(
child: widget.userInputForm,
child: widget.userInputForm!,
node: _focusNode,
autofocus: true,
),
... ... @@ -409,14 +409,14 @@ Set either a message or messageText""");
);
}
CurvedAnimation _progressAnimation;
late CurvedAnimation _progressAnimation;
GlobalKey backgroundBoxKey = GlobalKey();
Widget _generateSnack() {
return Container(
key: backgroundBoxKey,
constraints: widget.maxWidth != null
? BoxConstraints(maxWidth: widget.maxWidth)
? BoxConstraints(maxWidth: widget.maxWidth!)
: null,
decoration: BoxDecoration(
color: widget.backgroundColor,
... ... @@ -424,7 +424,7 @@ Set either a message or messageText""");
boxShadow: widget.boxShadows,
borderRadius: BorderRadius.circular(widget.borderRadius),
border: widget.borderColor != null
? Border.all(color: widget.borderColor, width: widget.borderWidth)
? Border.all(color: widget.borderColor!, width: widget.borderWidth!)
: null,
),
child: Column(
... ... @@ -618,7 +618,7 @@ Set either a message or messageText""");
return Container(
color: widget.leftBarIndicatorColor,
width: 5.0,
height: snapshot.data.height,
height: snapshot.data!.height,
);
} else {
return _emptyWidget;
... ... @@ -630,7 +630,7 @@ Set either a message or messageText""");
}
}
Widget _getIcon() {
Widget? _getIcon() {
if (widget.icon != null && widget.icon is Icon && widget.shouldIconPulse) {
return FadeTransition(
opacity: _fadeAnimation,
... ... @@ -659,7 +659,7 @@ Set either a message or messageText""");
);
}
Widget _getMainActionButton() {
Widget? _getMainActionButton() {
return widget.mainButton;
}
}
... ...
... ... @@ -6,17 +6,17 @@ import '../../get_navigation.dart';
import 'snack.dart';
class SnackRoute<T> extends OverlayRoute<T> {
Animation<double> _filterBlurAnimation;
Animation<Color> _filterColorAnimation;
late Animation<double> _filterBlurAnimation;
late Animation<Color?> _filterColorAnimation;
SnackRoute({
@required this.snack,
RouteSettings settings,
required this.snack,
RouteSettings? settings,
}) : super(settings: settings) {
_builder = Builder(builder: (_) {
return GestureDetector(
child: snack,
onTap: snack.onTap != null ? () => snack.onTap(snack) : null,
onTap: snack.onTap != null ? () => snack.onTap!(snack) : null,
);
});
... ... @@ -42,17 +42,17 @@ class SnackRoute<T> extends OverlayRoute<T> {
}
GetBar snack;
Builder _builder;
Builder? _builder;
final Completer<T> _transitionCompleter = Completer<T>();
SnackbarStatusCallback _snackbarStatus;
Alignment _initialAlignment;
Alignment _endAlignment;
late SnackbarStatusCallback _snackbarStatus;
Alignment? _initialAlignment;
Alignment? _endAlignment;
bool _wasDismissedBySwipe = false;
bool _onTappedDismiss = false;
Timer _timer;
Timer? _timer;
bool get opaque => false;
... ... @@ -93,7 +93,7 @@ class SnackRoute<T> extends OverlayRoute<T> {
builder: (context) {
final Widget annotatedChild = Semantics(
child: AlignTransition(
alignment: _animation,
alignment: _animation!,
child: snack.isDismissible
? _getDismissibleSnack(_builder)
: _getSnack(),
... ... @@ -112,7 +112,7 @@ class SnackRoute<T> extends OverlayRoute<T> {
String dismissibleKeyGen = "";
Widget _getDismissibleSnack(Widget child) {
Widget _getDismissibleSnack(Widget? child) {
return Dismissible(
direction: _getDismissDirection(),
resizeDuration: null,
... ... @@ -130,9 +130,9 @@ class SnackRoute<T> extends OverlayRoute<T> {
_wasDismissedBySwipe = true;
if (isCurrent) {
navigator.pop();
navigator!.pop();
} else {
navigator.removeRoute(this);
navigator!.removeRoute(this);
}
},
child: _getSnack(),
... ... @@ -159,16 +159,16 @@ class SnackRoute<T> extends OverlayRoute<T> {
@override
bool get finishedWhenPopped =>
_controller.status == AnimationStatus.dismissed;
_controller!.status == AnimationStatus.dismissed;
/// The animation that drives the route's transition and the previous route's
/// forward transition.
Animation<Alignment> _animation;
Animation<Alignment>? _animation;
/// The animation controller that the route uses to drive the transitions.
///
/// The animation itself is exposed by the [animation] property.
AnimationController _controller;
AnimationController? _controller;
/// Called to create the animation controller that will drive the transitions
/// to this route from the previous one, and back to the previous route
... ... @@ -181,7 +181,7 @@ class SnackRoute<T> extends OverlayRoute<T> {
return AnimationController(
duration: snack.animationDuration,
debugLabel: debugLabel,
vsync: navigator,
vsync: navigator!,
);
}
... ... @@ -194,7 +194,7 @@ class SnackRoute<T> extends OverlayRoute<T> {
assert(_controller != null);
return AlignmentTween(begin: _initialAlignment, end: _endAlignment).animate(
CurvedAnimation(
parent: _controller,
parent: _controller!,
curve: snack.forwardAnimationCurve,
reverseCurve: snack.reverseAnimationCurve,
),
... ... @@ -204,7 +204,7 @@ class SnackRoute<T> extends OverlayRoute<T> {
Animation<double> createBlurFilterAnimation() {
return Tween(begin: 0.0, end: snack.overlayBlur).animate(
CurvedAnimation(
parent: _controller,
parent: _controller!,
curve: Interval(
0.0,
0.35,
... ... @@ -214,11 +214,11 @@ class SnackRoute<T> extends OverlayRoute<T> {
);
}
Animation<Color> createColorFilterAnimation() {
Animation<Color?> createColorFilterAnimation() {
return ColorTween(begin: Color(0x00000000), end: snack.overlayColor)
.animate(
CurvedAnimation(
parent: _controller,
parent: _controller!,
curve: Interval(
0.0,
0.35,
... ... @@ -228,8 +228,8 @@ class SnackRoute<T> extends OverlayRoute<T> {
);
}
T _result;
SnackbarStatus currentStatus;
T? _result;
SnackbarStatus? currentStatus;
void _handleStatusChanged(AnimationStatus status) {
switch (status) {
... ... @@ -258,7 +258,7 @@ class SnackRoute<T> extends OverlayRoute<T> {
_snackbarStatus(currentStatus);
if (!isCurrent) {
navigator.finalizeRoute(this);
navigator!.finalizeRoute(this);
// assert(overlayEntries.isEmpty);
}
break;
... ... @@ -292,13 +292,13 @@ class SnackRoute<T> extends OverlayRoute<T> {
!_transitionCompleter.isCompleted,
'Cannot reuse a $runtimeType after disposing it.',
);
_animation.addStatusListener(_handleStatusChanged);
_animation!.addStatusListener(_handleStatusChanged);
_configureTimer();
return _controller.forward();
return _controller!.forward();
}
@override
void didReplace(Route<dynamic> oldRoute) {
void didReplace(Route<dynamic>? oldRoute) {
assert(
_controller != null,
// ignore: lines_longer_than_80_chars
... ... @@ -310,14 +310,14 @@ class SnackRoute<T> extends OverlayRoute<T> {
);
if (oldRoute is SnackRoute) {
_controller.value = oldRoute._controller.value;
_controller!.value = oldRoute._controller!.value;
}
_animation.addStatusListener(_handleStatusChanged);
_animation!.addStatusListener(_handleStatusChanged);
super.didReplace(oldRoute);
}
@override
bool didPop(T result) {
bool didPop(T? result) {
assert(
_controller != null,
// ignore: lines_longer_than_80_chars
... ... @@ -333,12 +333,12 @@ class SnackRoute<T> extends OverlayRoute<T> {
if (_wasDismissedBySwipe) {
Timer(Duration(milliseconds: 200), () {
_controller.reset();
_controller!.reset();
});
_wasDismissedBySwipe = false;
} else {
_controller.reverse();
_controller!.reverse();
}
return super.didPop(result);
... ... @@ -346,26 +346,26 @@ class SnackRoute<T> extends OverlayRoute<T> {
void _configureTimer() {
if (snack.duration != null) {
if (_timer != null && _timer.isActive) {
_timer.cancel();
if (_timer != null && _timer!.isActive) {
_timer!.cancel();
}
_timer = Timer(snack.duration, () {
_timer = Timer(snack.duration!, () {
if (isCurrent) {
navigator.pop();
navigator!.pop();
} else if (isActive) {
navigator.removeRoute(this);
navigator!.removeRoute(this);
}
});
} else {
if (_timer != null) {
_timer.cancel();
_timer!.cancel();
}
}
}
void _cancelTimer() {
if (_timer != null && _timer.isActive) {
_timer.cancel();
if (_timer != null && _timer!.isActive) {
_timer!.cancel();
}
}
... ...