diff --git a/packages/dart/lib/src/network/parse_live_query.dart b/packages/dart/lib/src/network/parse_live_query.dart index f30cfedf6..461453654 100644 --- a/packages/dart/lib/src/network/parse_live_query.dart +++ b/packages/dart/lib/src/network/parse_live_query.dart @@ -31,7 +31,7 @@ class Subscription { } } -enum LiveQueryClientEvent { CONNECTED, DISCONNECTED, USER_DISCONNECTED } +enum LiveQueryClientEvent { connected, disconnected, userDisconnected } class LiveQueryReconnectingController { LiveQueryReconnectingController( @@ -50,16 +50,16 @@ class LiveQueryReconnectingController { } _eventStream.listen((LiveQueryClientEvent event) { switch (event) { - case LiveQueryClientEvent.CONNECTED: + case LiveQueryClientEvent.connected: _isConnected = true; _retryState = 0; _userDisconnected = false; break; - case LiveQueryClientEvent.DISCONNECTED: + case LiveQueryClientEvent.disconnected: _isConnected = false; _setReconnect(); break; - case LiveQueryClientEvent.USER_DISCONNECTED: + case LiveQueryClientEvent.userDisconnected: _userDisconnected = true; Timer? currentTimer = _currentTimer; if (currentTimer != null) { @@ -70,14 +70,14 @@ class LiveQueryReconnectingController { } if (debug) { - print('$DEBUG_TAG: $event'); + print('$debugTag: $event'); } }); ParseCoreData().appResumedStream?.listen((void _) => _setReconnect()); } static List get retryInterval => ParseCoreData().liveListRetryIntervals; - static const String DEBUG_TAG = 'LiveQueryReconnectingController'; + static const String debugTag = 'LiveQueryReconnectingController'; final Function _reconnect; final Stream _eventStream; @@ -99,7 +99,7 @@ class LiveQueryReconnectingController { _isConnected = false; } if (debug) { - print('$DEBUG_TAG: $state'); + print('$debugTag: $state'); } _setReconnect(); } @@ -116,7 +116,7 @@ class LiveQueryReconnectingController { _reconnect(); }); if (debug) { - print('$DEBUG_TAG: Retrytimer set to ${retryInterval[_retryState]}ms'); + print('$debugTag: Retry timer set to ${retryInterval[_retryState]}ms'); } if (_retryState < retryInterval.length - 1) { _retryState++; @@ -188,13 +188,13 @@ class LiveQueryClient { if (webSocket != null) { return webSocket.readyState; } - return parse_web_socket.WebSocket.CONNECTING; + return parse_web_socket.WebSocket.connecting; } Future disconnect({bool userInitialized = false}) async { parse_web_socket.WebSocket? webSocket = _webSocket; if (webSocket != null && - webSocket.readyState == parse_web_socket.WebSocket.OPEN) { + webSocket.readyState == parse_web_socket.WebSocket.open) { if (_debug) { print('$_printConstLiveQuery: Socket closed'); } @@ -215,7 +215,7 @@ class LiveQueryClient { _connecting = false; if (userInitialized) { _clientEventStreamController.sink - .add(LiveQueryClientEvent.USER_DISCONNECTED); + .add(LiveQueryClientEvent.userDisconnected); } } @@ -224,7 +224,7 @@ class LiveQueryClient { {T? copyObject}) async { if (_webSocket == null) { await _clientEventStream.any((LiveQueryClientEvent event) => - event == LiveQueryClientEvent.CONNECTED); + event == LiveQueryClientEvent.connected); } final int requestId = _requestIdGenerator(); final Subscription subscription = @@ -272,7 +272,7 @@ class LiveQueryClient { await parse_web_socket.WebSocket.connect(_liveQueryURL); _webSocket = webSocket; _connecting = false; - if (webSocket.readyState == parse_web_socket.WebSocket.OPEN) { + if (webSocket.readyState == parse_web_socket.WebSocket.open) { if (_debug) { print('$_printConstLiveQuery: Socket opened'); } @@ -288,13 +288,13 @@ class LiveQueryClient { _handleMessage(message); }, onDone: () { _clientEventStreamController.sink - .add(LiveQueryClientEvent.DISCONNECTED); + .add(LiveQueryClientEvent.disconnected); if (_debug) { print('$_printConstLiveQuery: Done'); } }, onError: (Object error) { _clientEventStreamController.sink - .add(LiveQueryClientEvent.DISCONNECTED); + .add(LiveQueryClientEvent.disconnected); if (_debug) { print( '$_printConstLiveQuery: Error: ${error.runtimeType.toString()}'); @@ -307,7 +307,7 @@ class LiveQueryClient { }); } on Exception catch (e) { _connecting = false; - _clientEventStreamController.sink.add(LiveQueryClientEvent.DISCONNECTED); + _clientEventStreamController.sink.add(LiveQueryClientEvent.disconnected); if (_debug) { print('$_printConstLiveQuery: Error: ${e.toString()}'); } @@ -390,12 +390,12 @@ class LiveQueryClient { Subscription? subscription; if (actionData.containsKey('op') && actionData['op'] == 'connected') { - print('ReSubScription:$_requestSubscription'); + print('Re subscription:$_requestSubscription'); - _requestSubscription.values.toList().forEach((Subscription subcription) { - _subscribeLiveQuery(subcription); + _requestSubscription.values.toList().forEach((Subscription subscription) { + _subscribeLiveQuery(subscription); }); - _clientEventStreamController.sink.add(LiveQueryClientEvent.CONNECTED); + _clientEventStreamController.sink.add(LiveQueryClientEvent.connected); return; } if (actionData.containsKey('requestId')) { diff --git a/packages/dart/lib/src/network/parse_query.dart b/packages/dart/lib/src/network/parse_query.dart index 92bc647b4..ba989796e 100644 --- a/packages/dart/lib/src/network/parse_query.dart +++ b/packages/dart/lib/src/network/parse_query.dart @@ -18,7 +18,7 @@ class QueryBuilder { query += '{' + list[i].buildQueries(list[i].queries) + '}'; } query += ']'; - queries.add(MapEntry(_NO_OPERATOR_NEEDED, query)); + queries.add(MapEntry(_noOperatorNeeded, query)); } factory QueryBuilder.copy(QueryBuilder query) { @@ -32,8 +32,8 @@ class QueryBuilder { return copy; } - static const String _NO_OPERATOR_NEEDED = 'NO_OP'; - static const String _SINGLE_QUERY = 'SINGLE_QUERY'; + static const String _noOperatorNeeded = 'NO_OP'; + static const String _singleQuery = 'SINGLE_QUERY'; T object; List> queries = >[]; @@ -103,10 +103,10 @@ class QueryBuilder { {bool caseSensitive = false}) { if (caseSensitive) { queries.add(MapEntry( - _SINGLE_QUERY, '"$column":{"\$regex": "^$query"}')); + _singleQuery, '"$column":{"\$regex": "^$query"}')); } else { queries.add(MapEntry( - _SINGLE_QUERY, '"$column":{"\$regex": "^$query", "\$options": "i"}')); + _singleQuery, '"$column":{"\$regex": "^$query", "\$options": "i"}')); } } @@ -115,17 +115,17 @@ class QueryBuilder { {bool caseSensitive = false}) { if (caseSensitive) { queries.add(MapEntry( - _SINGLE_QUERY, '"$column":{"\$regex": "$query\$"}')); + _singleQuery, '"$column":{"\$regex": "$query\$"}')); } else { - queries.add(MapEntry(_SINGLE_QUERY, - '"$column":{"\$regex": "$query\$", "\$options": "i"}')); + queries.add(MapEntry( + _singleQuery, '"$column":{"\$regex": "$query\$", "\$options": "i"}')); } } /// Returns an object where the [String] column equals [value] void whereEqualTo(String column, dynamic value) { queries.add(_buildQueryWithColumnValueAndOperator( - MapEntry(column, value), _NO_OPERATOR_NEEDED)); + MapEntry(column, value), _noOperatorNeeded)); } /// Returns an object where the [String] column contains a value less than @@ -182,7 +182,7 @@ class QueryBuilder { /// Retrieves related objets where [String] column is a relation field to the class [String] className void whereRelatedTo(String column, String className, String objectId) { - queries.add(MapEntry(_SINGLE_QUERY, + queries.add(MapEntry(_singleQuery, '"\$relatedTo":{"object":{"__type":"Pointer","className":"$className","objectId":"$objectId"},"key":"$column"}')); } @@ -216,20 +216,20 @@ class QueryBuilder { {bool caseSensitive = false}) { if (caseSensitive) { queries.add(MapEntry( - _SINGLE_QUERY, '"$column":{"\$regex": "$value"}')); + _singleQuery, '"$column":{"\$regex": "$value"}')); } else { queries.add(MapEntry( - _SINGLE_QUERY, '"$column":{"\$regex": "$value", "\$options": "i"}')); + _singleQuery, '"$column":{"\$regex": "$value", "\$options": "i"}')); } } - /// Powerful search for containing whole words. This search is much quicker than regex and can search for whole words including wether they are case sensitive or not. + /// Powerful search for containing whole words. This search is much quicker than regex and can search for whole words including whether they are case sensitive or not. /// This search can also order by the score of the search void whereContainsWholeWord(String column, String query, {bool caseSensitive = false, bool orderByScore = true, bool diacriticSensitive = false}) { - queries.add(MapEntry(_SINGLE_QUERY, + queries.add(MapEntry(_singleQuery, '"$column":{"\$text":{"\$search":{"\$term": "$query", "\$caseSensitive": $caseSensitive , "\$diacriticSensitive": $diacriticSensitive }}}')); if (orderByScore) { orderByAscending('\$score'); @@ -241,7 +241,7 @@ class QueryBuilder { void whereNear(String column, ParseGeoPoint point) { final double latitude = point.latitude; final double longitude = point.longitude; - queries.add(MapEntry(_SINGLE_QUERY, + queries.add(MapEntry(_singleQuery, '"$column":{"\$nearSphere":{"__type":"GeoPoint","latitude":$latitude,"longitude":$longitude}}')); } @@ -251,7 +251,7 @@ class QueryBuilder { final double latitude = point.latitude; final double longitude = point.longitude; - queries.add(MapEntry(_SINGLE_QUERY, + queries.add(MapEntry(_singleQuery, '"$column":{"\$nearSphere":{"__type":"GeoPoint","latitude":$latitude,"longitude":$longitude},"\$maxDistanceInMiles":$maxDistance}')); } @@ -261,7 +261,7 @@ class QueryBuilder { final double latitude = point.latitude; final double longitude = point.longitude; - queries.add(MapEntry(_SINGLE_QUERY, + queries.add(MapEntry(_singleQuery, '"$column":{"\$nearSphere":{"__type":"GeoPoint","latitude":$latitude,"longitude":$longitude},"\$maxDistanceInKilometers":$maxDistance}')); } @@ -271,7 +271,7 @@ class QueryBuilder { final double latitude = point.latitude; final double longitude = point.longitude; - queries.add(MapEntry(_SINGLE_QUERY, + queries.add(MapEntry(_singleQuery, '"$column":{"\$nearSphere":{"__type":"GeoPoint","latitude":$latitude,"longitude":$longitude},"\$maxDistanceInRadians":$maxDistance}')); } @@ -284,7 +284,7 @@ class QueryBuilder { final double latitudeN = northeast.latitude; final double longitudeN = northeast.longitude; - queries.add(MapEntry(_SINGLE_QUERY, + queries.add(MapEntry(_singleQuery, '"$column":{"\$within":{"\$box": [{"__type": "GeoPoint","latitude":$latitudeS,"longitude":$longitudeS},{"__type": "GeoPoint","latitude":$latitudeN,"longitude":$longitudeN}]}}')); } @@ -299,7 +299,7 @@ class QueryBuilder { dictionary['\$polygon'] = points.map((e) => e.toJson()).toList(); queries.add(MapEntry( - _SINGLE_QUERY, '"$column":{"\$geoWithin":${jsonEncode(dictionary)}}')); + _singleQuery, '"$column":{"\$geoWithin":${jsonEncode(dictionary)}}')); } /// Add a constraint to the query that requires a particular key's value match another QueryBuilder @@ -309,7 +309,7 @@ class QueryBuilder { query._buildQueryRelational(query.object.parseClassName); queries.add(MapEntry( - _SINGLE_QUERY, '"$column":{"\$inQuery":$inQuery}')); + _singleQuery, '"$column":{"\$inQuery":$inQuery}')); } ///Add a constraint to the query that requires a particular key's value does not match another QueryBuilder @@ -319,7 +319,7 @@ class QueryBuilder { query._buildQueryRelational(query.object.parseClassName); queries.add(MapEntry( - _SINGLE_QUERY, '"$column":{"\$notInQuery":$inQuery}')); + _singleQuery, '"$column":{"\$notInQuery":$inQuery}')); } /// Add a constraint to the query that requires a particular key's value matches a value for a key in the results of another ParseQuery. @@ -339,7 +339,7 @@ class QueryBuilder { query._buildQueryRelationalKey(query.object.parseClassName, keyInQuery); queries.add(MapEntry( - _SINGLE_QUERY, '"$column":{"\$select":$inQuery}')); + _singleQuery, '"$column":{"\$select":$inQuery}')); } /// Add a constraint to the query that requires a particular key's value does not match any value for a key in the results of another ParseQuery @@ -359,7 +359,7 @@ class QueryBuilder { query._buildQueryRelationalKey(query.object.parseClassName, keyInQuery); queries.add(MapEntry( - _SINGLE_QUERY, '"$column":{"\$dontSelect":$inQuery}')); + _singleQuery, '"$column":{"\$dontSelect":$inQuery}')); } /// Finishes the query and calls the server @@ -445,9 +445,9 @@ class QueryBuilder { final dynamic value = convertValueToCorrectType(parseEncode(columnAndValue.value)); - if (queryOperator == _NO_OPERATOR_NEEDED) { + if (queryOperator == _noOperatorNeeded) { return MapEntry( - _NO_OPERATOR_NEEDED, '"$key": ${jsonEncode(value)}'); + _noOperatorNeeded, '"$key": ${jsonEncode(value)}'); } else { String queryString = '"$key":'; final Map queryOperatorAndValueMap = {}; @@ -470,15 +470,15 @@ class QueryBuilder { // Run through each query for (final MapEntry query in queries) { // Add queries that don't need sanitizing - if (query.key == _NO_OPERATOR_NEEDED || query.key == _SINGLE_QUERY) { + if (query.key == _noOperatorNeeded || query.key == _singleQuery) { sanitizedQueries - .add(MapEntry(_NO_OPERATOR_NEEDED, query.value)); + .add(MapEntry(_noOperatorNeeded, query.value)); } // Check if query with same column name has been sanitized if (!keysAlreadyCompacted.contains(query.key) && - query.key != _NO_OPERATOR_NEEDED && - query.key != _SINGLE_QUERY) { + query.key != _noOperatorNeeded && + query.key != _singleQuery) { // If not, check that it now has keysAlreadyCompacted.add(query.key); diff --git a/packages/dart/lib/src/network/parse_websocket_html.dart b/packages/dart/lib/src/network/parse_websocket_html.dart index 1ad8a3007..35593e9a8 100644 --- a/packages/dart/lib/src/network/parse_websocket_html.dart +++ b/packages/dart/lib/src/network/parse_websocket_html.dart @@ -8,10 +8,10 @@ import 'package:web_socket_channel/web_socket_channel.dart'; class WebSocket { WebSocket._(this._webSocket); - static const int CONNECTING = 0; - static const int OPEN = 1; - static const int CLOSING = 2; - static const int CLOSED = 3; + static const int connecting = 0; + static const int open = 1; + static const int closing = 2; + static const int closed = 3; final html.WebSocket _webSocket; diff --git a/packages/dart/lib/src/network/parse_websocket_io.dart b/packages/dart/lib/src/network/parse_websocket_io.dart index fb69bd5fa..b2cd15503 100644 --- a/packages/dart/lib/src/network/parse_websocket_io.dart +++ b/packages/dart/lib/src/network/parse_websocket_io.dart @@ -8,10 +8,10 @@ import 'package:web_socket_channel/web_socket_channel.dart'; class WebSocket { WebSocket._(this._webSocket); - static const int CONNECTING = 0; - static const int OPEN = 1; - static const int CLOSING = 2; - static const int CLOSED = 3; + static const int connecting = 0; + static const int open = 1; + static const int closing = 2; + static const int closed = 3; final io.WebSocket _webSocket; diff --git a/packages/dart/lib/src/utils/parse_live_list.dart b/packages/dart/lib/src/utils/parse_live_list.dart index a572afdb9..1dd2798b3 100644 --- a/packages/dart/lib/src/utils/parse_live_list.dart +++ b/packages/dart/lib/src/utils/parse_live_list.dart @@ -200,7 +200,7 @@ class ParseLiveList { .client .getClientEventStream .listen((LiveQueryClientEvent event) async { - if (event == LiveQueryClientEvent.CONNECTED) { + if (event == LiveQueryClientEvent.connected) { _updateQueue.whenComplete(() async { List> tasks = >[]; final ParseResponse parseResponse = await _runQuery(); @@ -533,7 +533,7 @@ class ParseLiveElement extends ParseLiveListElement { _subscriptionQueue.whenComplete(() async { // ignore: missing_enum_constant_in_switch switch (event) { - case LiveQueryClientEvent.CONNECTED: + case LiveQueryClientEvent.connected: final ParseResponse parseResponse = await queryBuilder.query(); if (parseResponse.success) { super.object = parseResponse.result.first; diff --git a/packages/flutter/analysis_options.yaml b/packages/flutter/analysis_options.yaml index fd16f9219..a51fa3b93 100644 --- a/packages/flutter/analysis_options.yaml +++ b/packages/flutter/analysis_options.yaml @@ -22,7 +22,7 @@ linter: # `// ignore_for_file: name_of_lint` syntax on the line or in the file # producing the lint. rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule + avoid_print: false # Uncomment to disable the `avoid_print` rule # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options diff --git a/packages/flutter/example/lib/pages/login_page.dart b/packages/flutter/example/lib/pages/login_page.dart index c91ab0286..a9952c9e3 100644 --- a/packages/flutter/example/lib/pages/login_page.dart +++ b/packages/flutter/example/lib/pages/login_page.dart @@ -236,7 +236,7 @@ class _LoginPageState extends State { height: 40.0, child: ElevatedButton( style: ElevatedButton.styleFrom( - primary: Colors.blue, + backgroundColor: Colors.blue, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30.0)), elevation: 5.0, diff --git a/packages/flutter/example/linux/flutter/generated_plugins.cmake b/packages/flutter/example/linux/flutter/generated_plugins.cmake index 51436ae8c..2e1de87a7 100644 --- a/packages/flutter/example/linux/flutter/generated_plugins.cmake +++ b/packages/flutter/example/linux/flutter/generated_plugins.cmake @@ -5,6 +5,9 @@ list(APPEND FLUTTER_PLUGIN_LIST ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/packages/flutter/lib/generated/i18n.dart b/packages/flutter/lib/generated/i18n.dart deleted file mode 100644 index a4ee41961..000000000 --- a/packages/flutter/lib/generated/i18n.dart +++ /dev/null @@ -1,74 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; - -// ignore_for_file: non_constant_identifier_names -// ignore_for_file: camel_case_types -// ignore_for_file: prefer_single_quotes - -//This file is automatically generated. DO NOT EDIT, all your changes would be lost. - -class S implements WidgetsLocalizations { - const S(); - - static const GeneratedLocalizationsDelegate delegate = - GeneratedLocalizationsDelegate(); - - static S? of(BuildContext context) => - Localizations.of(context, WidgetsLocalizations); - - @override - TextDirection get textDirection => TextDirection.ltr; -} - -class en extends S { - const en(); -} - -class GeneratedLocalizationsDelegate - extends LocalizationsDelegate { - const GeneratedLocalizationsDelegate(); - - List get supportedLocales { - return const [ - Locale("en", ""), - ]; - } - - LocaleResolutionCallback resolution({Locale? fallback}) { - return (Locale? locale, Iterable supported) { - final Locale languageLocale = Locale(locale!.languageCode, ""); - if (supported.contains(locale)) - return locale; - else if (supported.contains(languageLocale)) - return languageLocale; - else { - final Locale fallbackLocale = fallback ?? supported.first; - return fallbackLocale; - } - }; - } - - @override - Future load(Locale locale) { - final String lang = getLang(locale); - switch (lang) { - case "en": - return SynchronousFuture(const en()); - - default: - return SynchronousFuture(const S()); - } - } - - @override - bool isSupported(Locale locale) => supportedLocales.contains(locale); - - @override - bool shouldReload(GeneratedLocalizationsDelegate old) => false; -} - -String getLang(Locale l) => l.countryCode != null && l.countryCode!.isEmpty - ? l.languageCode - : l.toString(); diff --git a/packages/flutter/lib/src/utils/parse_live_grid.dart b/packages/flutter/lib/src/utils/parse_live_grid.dart index 646f5735d..13503ebaa 100644 --- a/packages/flutter/lib/src/utils/parse_live_grid.dart +++ b/packages/flutter/lib/src/utils/parse_live_grid.dart @@ -57,14 +57,7 @@ class ParseLiveGridWidget extends StatefulWidget { final double childAspectRatio; @override - _ParseLiveGridWidgetState createState() => _ParseLiveGridWidgetState( - query: query, - removedItemBuilder: removedItemBuilder, - listenOnAllSubItems: listenOnAllSubItems, - listeningIncludes: listeningIncludes, - lazyLoading: lazyLoading, - preloadedColumns: preloadedColumns, - ); + _ParseLiveGridWidgetState createState() => _ParseLiveGridWidgetState(); static Widget defaultChildBuilder( BuildContext context, sdk.ParseLiveListElementSnapshot snapshot) { @@ -88,19 +81,17 @@ class ParseLiveGridWidget extends StatefulWidget { class _ParseLiveGridWidgetState extends State> { - _ParseLiveGridWidgetState( - {required this.query, - required this.removedItemBuilder, - bool? listenOnAllSubItems, - List? listeningIncludes, - bool lazyLoading = true, - List? preloadedColumns}) { + sdk.ParseLiveList? _liveGrid; + bool noData = true; + + @override + void initState() { sdk.ParseLiveList.create( - query, - listenOnAllSubItems: listenOnAllSubItems, - listeningIncludes: listeningIncludes, - lazyLoading: lazyLoading, - preloadedColumns: preloadedColumns, + widget.query, + listenOnAllSubItems: widget.listenOnAllSubItems, + listeningIncludes: widget.listeningIncludes, + lazyLoading: widget.lazyLoading, + preloadedColumns: widget.preloadedColumns, ).then((sdk.ParseLiveList value) { if (value.size > 0) { setState(() { @@ -121,12 +112,9 @@ class _ParseLiveGridWidgetState }); }); }); - } - final sdk.QueryBuilder query; - sdk.ParseLiveList? _liveGrid; - final ChildBuilder? removedItemBuilder; - bool noData = true; + super.initState(); + } @override Widget build(BuildContext context) { diff --git a/packages/flutter/lib/src/utils/parse_live_list.dart b/packages/flutter/lib/src/utils/parse_live_list.dart index 7c52b4678..5f013229b 100644 --- a/packages/flutter/lib/src/utils/parse_live_list.dart +++ b/packages/flutter/lib/src/utils/parse_live_list.dart @@ -51,14 +51,7 @@ class ParseLiveListWidget extends StatefulWidget { final List? preloadedColumns; @override - _ParseLiveListWidgetState createState() => _ParseLiveListWidgetState( - query: query, - removedItemBuilder: removedItemBuilder, - listenOnAllSubItems: listenOnAllSubItems, - listeningIncludes: listeningIncludes, - lazyLoading: lazyLoading, - preloadedColumns: preloadedColumns, - ); + _ParseLiveListWidgetState createState() => _ParseLiveListWidgetState(); static Widget defaultChildBuilder( BuildContext context, sdk.ParseLiveListElementSnapshot snapshot) { @@ -83,24 +76,19 @@ class ParseLiveListWidget extends StatefulWidget { class _ParseLiveListWidgetState extends State> { - _ParseLiveListWidgetState( - {required this.query, - required this.removedItemBuilder, - bool? listenOnAllSubItems, - List? listeningIncludes, - bool lazyLoading = true, - List? preloadedColumns}) { + @override + void initState() { sdk.ParseLiveList.create( - query, - listenOnAllSubItems: listenOnAllSubItems, - listeningIncludes: listeningIncludes, - lazyLoading: lazyLoading, - preloadedColumns: preloadedColumns, - ).then((sdk.ParseLiveList livelist) { + widget.query, + listenOnAllSubItems: widget.listenOnAllSubItems, + listeningIncludes: widget.listeningIncludes, + lazyLoading: widget.lazyLoading, + preloadedColumns: widget.preloadedColumns, + ).then((sdk.ParseLiveList liveList) { setState(() { - _noData = livelist.size == 0; - _liveList = livelist; - livelist.stream.listen((sdk.ParseLiveListEvent event) { + _noData = liveList.size == 0; + _liveList = liveList; + liveList.stream.listen((sdk.ParseLiveListEvent event) { final AnimatedListState? animatedListState = _animatedListKey.currentState; if (animatedListState != null) { @@ -109,7 +97,7 @@ class _ParseLiveListWidgetState duration: widget.duration); setState(() { - _noData = livelist.size == 0; + _noData = liveList.size == 0; }); } else if (event is sdk.ParseLiveListDeleteEvent) { animatedListState.removeItem( @@ -128,20 +116,20 @@ class _ParseLiveListWidgetState ), duration: widget.duration); setState(() { - _noData = livelist.size == 0; + _noData = liveList.size == 0; }); } } }); }); }); + + super.initState(); } - final sdk.QueryBuilder query; sdk.ParseLiveList? _liveList; final GlobalKey _animatedListKey = GlobalKey(); - final ChildBuilder? removedItemBuilder; bool _noData = true; @override @@ -226,22 +214,24 @@ class ParseLiveListElementWidget @override _ParseLiveListElementWidgetState createState() { - return _ParseLiveListElementWidgetState( - loadedData, preLoadedData, stream); + return _ParseLiveListElementWidgetState(); } } class _ParseLiveListElementWidgetState extends State> with SingleTickerProviderStateMixin { - _ParseLiveListElementWidgetState(DataGetter? loadedDataGetter, - DataGetter? preLoadedDataGetter, StreamGetter? stream) { + late sdk.ParseLiveListElementSnapshot _snapshot; + StreamSubscription? _streamSubscription; + + @override + void initState() { _snapshot = sdk.ParseLiveListElementSnapshot( - loadedData: loadedDataGetter != null ? loadedDataGetter() : null, + loadedData: widget.loadedData != null ? widget.loadedData!() : null, preLoadedData: - preLoadedDataGetter != null ? preLoadedDataGetter() : null); - if (stream != null) { - _streamSubscription = stream().listen( + widget.preLoadedData != null ? widget.preLoadedData!() : null); + if (widget.stream != null) { + _streamSubscription = widget.stream!().listen( (T data) { setState(() { _snapshot = sdk.ParseLiveListElementSnapshot( @@ -258,11 +248,9 @@ class _ParseLiveListElementWidgetState cancelOnError: false, ); } - } - late sdk.ParseLiveListElementSnapshot _snapshot; - - StreamSubscription? _streamSubscription; + super.initState(); + } @override void setState(VoidCallback fn) {