Skip to content

Commit 3163da6

Browse files
committed
Release/1.0.26 - Code formatting, remove lint issues
1 parent bb4eef6 commit 3163da6

File tree

14 files changed

+152
-108
lines changed

14 files changed

+152
-108
lines changed

example/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class _MyAppState extends State<MyApp> {
6868
Future<void> initData() async {
6969
// Initialize repository
7070
await initRepository();
71-
final CoreStore coreStore = await initCoreStore();
71+
await initCoreStore();
7272

7373
// Initialize parse
7474
await Parse().initialize(keyParseApplicationId, keyParseServerUrl,
@@ -233,7 +233,7 @@ class _MyAppState extends State<MyApp> {
233233
user = response.result;
234234
}*/
235235

236-
ParseUser user1 = await ParseUser.currentUser();
236+
final ParseUser user1 = await ParseUser.currentUser();
237237
user1.authData;
238238

239239
/// Login

example/lib/pages/home_page.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class _HomePageState extends State<HomePage> {
7474
if (snapshot.data.success) {
7575
if (snapshot.data.results == null ||
7676
snapshot.data.results.isEmpty) {
77-
return Center(
78-
child: const Text('No Data'),
77+
return const Center(
78+
child: Text('No Data'),
7979
);
8080
}
8181
}
@@ -97,7 +97,7 @@ class _HomePageState extends State<HomePage> {
9797
child: ListTile(
9898
title: Text(
9999
name,
100-
style: TextStyle(fontSize: 20.0),
100+
style: const TextStyle(fontSize: 20.0),
101101
),
102102
subtitle: Text(description),
103103
trailing: IconButton(
@@ -118,8 +118,8 @@ class _HomePageState extends State<HomePage> {
118118
);
119119
});
120120
} else {
121-
return Center(
122-
child: const Text('No Data'),
121+
return const Center(
122+
child: Text('No Data'),
123123
);
124124
}
125125
});

example/lib/pages/login_page.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class _LoginPageState extends State<LoginPage> {
114114

115115
Widget _showCircularProgress() {
116116
if (_isLoading) {
117-
return Center(child: const CircularProgressIndicator());
117+
return const Center(child: CircularProgressIndicator());
118118
}
119119
return Container(
120120
height: 0.0,
@@ -179,9 +179,9 @@ class _LoginPageState extends State<LoginPage> {
179179
maxLines: 1,
180180
keyboardType: TextInputType.emailAddress,
181181
autofocus: false,
182-
decoration: InputDecoration(
182+
decoration: const InputDecoration(
183183
hintText: 'Email',
184-
icon: const Icon(
184+
icon: Icon(
185185
Icons.mail,
186186
color: Colors.grey,
187187
)),
@@ -199,9 +199,9 @@ class _LoginPageState extends State<LoginPage> {
199199
maxLines: 1,
200200
obscureText: true,
201201
autofocus: false,
202-
decoration: InputDecoration(
202+
decoration: const InputDecoration(
203203
hintText: 'Password',
204-
icon: const Icon(
204+
icon: Icon(
205205
Icons.lock,
206206
color: Colors.grey,
207207
)),

example/test/data/repository/diet_plan/repository_diet_plan_api_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ void main() {
100100
// When
101101
final ApiResponse baseResponse = await repository.add(dummy);
102102
final ApiResponse responseWithResult = await repository
103-
.getNewerThan(DateTime.now().subtract(Duration(days: 1)));
103+
.getNewerThan(DateTime.now().subtract(const Duration(days: 1)));
104104
final ApiResponse responseWithoutResult =
105-
await repository.getNewerThan(DateTime.now().add(Duration(days: 1)));
105+
await repository.getNewerThan(
106+
DateTime.now().add(const Duration(days: 1)));
106107

107108
// CLEAR FROM DB
108109
await deleteFromApi(baseResponse.results);

example/test/data/repository/diet_plan/repository_diet_plan_db_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void main() {
131131

132132
// When
133133
DateTime dateTime = DateTime.now();
134-
dateTime = dateTime.subtract(Duration(hours: 1));
134+
dateTime = dateTime.subtract(const Duration(hours: 1));
135135
final ApiResponse updateResponse = await repository.getNewerThan(dateTime);
136136
final List<DietPlan> actual = updateResponse.results;
137137

example_livelist/test/widget_test.dart

Lines changed: 0 additions & 30 deletions
This file was deleted.

lib/src/network/parse_live_query.dart

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Subscription<T extends ParseObject> {
1717
Subscription(this.query, this.requestId, {T copyObject}) {
1818
_copyObject = copyObject;
1919
}
20+
2021
QueryBuilder<T> query;
2122
T _copyObject;
2223
int requestId;
@@ -30,6 +31,7 @@ class Subscription<T extends ParseObject> {
3031
'error'
3132
];
3233
Map<String, Function> eventCallbacks = <String, Function>{};
34+
3335
void on(LiveQueryEvent op, Function callback) {
3436
eventCallbacks[_liveQueryEvent[op.index]] = callback;
3537
}
@@ -42,21 +44,6 @@ class Subscription<T extends ParseObject> {
4244
enum LiveQueryClientEvent { CONNECTED, DISCONNECTED, USER_DISCONNECTED }
4345

4446
class LiveQueryReconnectingController with WidgetsBindingObserver {
45-
// -1 means "do not try to reconnect",
46-
static const List<int> retryInterval = [0, 500, 1000, 2000, 5000, 10000];
47-
static const String DEBUG_TAG = 'LiveQueryReconnectingController';
48-
49-
final Function _reconnect;
50-
final Stream<LiveQueryClientEvent> _eventStream;
51-
final bool debug;
52-
53-
int _retryState = 0;
54-
bool _isOnline = false;
55-
bool _isConnected = false;
56-
bool _userDisconnected = false;
57-
58-
Timer _currentTimer;
59-
6047
LiveQueryReconnectingController(
6148
this._reconnect, this._eventStream, this.debug) {
6249
Connectivity().checkConnectivity().then(_connectivityChanged);
@@ -82,15 +69,36 @@ class LiveQueryReconnectingController with WidgetsBindingObserver {
8269
break;
8370
}
8471

85-
if (debug) print('$DEBUG_TAG: $event');
72+
if (debug) {
73+
print('$DEBUG_TAG: $event');
74+
}
8675
});
8776
WidgetsBinding.instance.addObserver(this);
8877
}
8978

79+
// -1 means "do not try to reconnect",
80+
static const List<int> retryInterval = <int>[0, 500, 1000, 2000, 5000, 10000];
81+
static const String DEBUG_TAG = 'LiveQueryReconnectingController';
82+
83+
final Function _reconnect;
84+
final Stream<LiveQueryClientEvent> _eventStream;
85+
final bool debug;
86+
87+
int _retryState = 0;
88+
bool _isOnline = false;
89+
bool _isConnected = false;
90+
bool _userDisconnected = false;
91+
92+
Timer _currentTimer;
93+
9094
void _connectivityChanged(ConnectivityResult state) {
91-
if (!_isOnline && state != ConnectivityResult.none) _retryState = 0;
95+
if (!_isOnline && state != ConnectivityResult.none) {
96+
_retryState = 0;
97+
}
9298
_isOnline = state != ConnectivityResult.none;
93-
if (debug) print('$DEBUG_TAG: $state');
99+
if (debug) {
100+
print('$DEBUG_TAG: $state');
101+
}
94102
_setReconnect();
95103
}
96104

@@ -118,13 +126,16 @@ class LiveQueryReconnectingController with WidgetsBindingObserver {
118126
});
119127
if (debug)
120128
print('$DEBUG_TAG: Retrytimer set to ${retryInterval[_retryState]}ms');
121-
if (_retryState < retryInterval.length - 1) _retryState++;
129+
if (_retryState < retryInterval.length - 1) {
130+
_retryState++;
131+
}
122132
}
123133
}
124134
}
125135

126136
class Client {
127137
factory Client() => _getInstance();
138+
128139
Client._internal(
129140
{bool debug, ParseHTTPClient client, bool autoSendSessionId}) {
130141
_clientEventStreamController = StreamController<LiveQueryClientEvent>();
@@ -150,8 +161,10 @@ class Client {
150161
reconnectingController = LiveQueryReconnectingController(
151162
() => reconnect(userInitialized: false), getClientEventStream, _debug);
152163
}
164+
153165
static Client get instance => _getInstance();
154166
static Client _instance;
167+
155168
static Client _getInstance(
156169
{bool debug, ParseHTTPClient client, bool autoSendSessionId}) {
157170
_instance ??= Client._internal(
@@ -174,6 +187,7 @@ class Client {
174187
Stream<LiveQueryClientEvent> _clientEventStream;
175188
LiveQueryReconnectingController reconnectingController;
176189

190+
// ignore: always_specify_types
177191
final Map<int, Subscription> _requestSubScription = <int, Subscription>{};
178192

179193
Future<void> reconnect({bool userInitialized = false}) async {
@@ -203,8 +217,9 @@ class Client {
203217
await _channel.sink.close();
204218
_channel = null;
205219
}
206-
_requestSubScription.values.toList().forEach((Subscription subcription) {
207-
subcription._enabled = false;
220+
// ignore: always_specify_types
221+
_requestSubScription.values.toList().forEach((Subscription subscription) {
222+
subscription._enabled = false;
208223
});
209224
_connecting = false;
210225
if (userInitialized)
@@ -327,12 +342,14 @@ class Client {
327342
_channel.sink.add(jsonEncode(connectMessage));
328343
}
329344

345+
// ignore: always_specify_types
330346
void _subscribeLiveQuery(Subscription subscription) {
331347
if (subscription._enabled) {
332348
return;
333349
}
334350
subscription._enabled = true;
335-
QueryBuilder query = subscription.query;
351+
// ignore: always_specify_types
352+
final QueryBuilder query = subscription.query;
336353
final List<String> keysToReturn = query.limiters['keys']?.split(',');
337354
query.limiters.clear(); //Remove limits in LiveQuery
338355
final String _where = query.buildQuery().replaceAll('where=', '');
@@ -370,9 +387,11 @@ class Client {
370387
}
371388

372389
final Map<String, dynamic> actionData = jsonDecode(message);
390+
// ignore: always_specify_types
373391
Subscription subscription;
374392
if (actionData.containsKey('op') && actionData['op'] == 'connected') {
375393
print('ReSubScription:$_requestSubScription');
394+
// ignore: always_specify_types
376395
_requestSubScription.values.toList().forEach((Subscription subcription) {
377396
_subscribeLiveQuery(subcription);
378397
});
@@ -423,11 +442,14 @@ class LiveQuery {
423442
ParseHTTPClient _client;
424443
bool _debug;
425444
bool _sendSessionId;
445+
446+
// ignore: always_specify_types
426447
Subscription _latestSubscription;
427448
Client client;
428449

429450
// ignore: always_specify_types
430451
@deprecated
452+
// ignore: always_specify_types
431453
Future<dynamic> subscribe(QueryBuilder query) async {
432454
_latestSubscription = await client.subscribe(query);
433455
return _latestSubscription;

0 commit comments

Comments
 (0)