fix(analyze): Fix the analizer issues
MODIFY
example/lib/graphql_bloc/bloc.dart
example/lib/graphql_bloc/bloc.dart
@@ -4,9 +4,7 @@ import 'package:graphql_flutter/graphql_flutter.dart';
import '../graphql_operation/mutations/mutations.dart' as mutations;
import '../graphql_operation/queries/readRepositories.dart' as queries;
-/// Create a ../local.dart file with YOUR_PERSONAL_ACCESS_TOKEN = '<YOUR_PERSONAL_ACCESS_TOKEN>'
-/// to make the example work
-import '../local.dart' show YOUR_PERSONAL_ACCESS_TOKEN;
+const String YOUR_PERSONAL_ACCESS_TOKEN = '<YOUR_PERSONAL_ACCESS_TOKEN>';
class Repo {
const Repo({this.id, this.name, this.viewerHasStarred});

MODIFY
example/lib/graphql_widget/main.dart
example/lib/graphql_widget/main.dart
@@ -4,11 +4,9 @@ import 'package:graphql_flutter/graphql_flutter.dart';
import '../graphql_operation/mutations/mutations.dart' as mutations;
import '../graphql_operation/queries/readRepositories.dart' as queries;
-/// Create a ../local.dart file with YOUR_PERSONAL_ACCESS_TOKEN = '<YOUR_PERSONAL_ACCESS_TOKEN>'
-/// to make the example work
-import '../local.dart' show YOUR_PERSONAL_ACCESS_TOKEN;
+const String YOUR_PERSONAL_ACCESS_TOKEN = '<YOUR_PERSONAL_ACCESS_TOKEN>';
-final bool ENABLE_WEBSOCKETS = false;
+const bool ENABLE_WEBSOCKETS = false;
class GraphQLWidgetScreen extends StatelessWidget {
const GraphQLWidgetScreen() : super();
@@ -186,7 +184,7 @@ class StarrableRepository extends StatelessWidget {
document: starred ? mutations.removeStar : mutations.addStar,
),
builder: (RunMutation toggleStar, QueryResult result) {
- print([result.loading, optimistic]);
+ print(<bool>[result.loading, optimistic]);
return ListTile(
leading: starred
? const Icon(

MODIFY
lib/src/cache/in_memory.dart
lib/src/cache/in_memory.dart
@@ -126,7 +126,7 @@ class InMemoryCache implements Cache {
}
try {
final File file = await _localStorageFile;
- final storedHashMap = HashMap<String, dynamic>();
+ final HashMap<String, dynamic> storedHashMap = HashMap<String, dynamic>();
if (file.existsSync()) {
final Stream<List<int>> inputStream = file.openRead();

MODIFY
lib/src/cache/lazy_cache_map.dart
lib/src/cache/lazy_cache_map.dart
import 'dart:core';
-import 'dart:collection';
import 'package:meta/meta.dart';
@@ -13,7 +12,7 @@ class LazyCacheMap extends LazyDereferencingMap {
Map<String, Object> data, {
@required Dereference dereference,
CacheState cacheState,
- }) : this.cacheState =
+ }) : cacheState =
cacheState ?? (data is LazyCacheMap ? data.cacheState : null),
super(data, dereference: dereference);

MODIFY
lib/src/cache/optimistic.dart
lib/src/cache/optimistic.dart
@@ -146,9 +146,9 @@ class OptimisticCache extends NormalizedInMemoryCache {
patch.id == removeId || _parentPatchId(patch.id) == removeId,
);
- print([
+ print(<dynamic>[
optimisticPatches.length,
- optimisticPatches.map((p) => p.id),
+ optimisticPatches.map<String>((OptimisticPatch p) => p.id),
removeId
]);
}

MODIFY
lib/src/core/raw_operation_data.dart
lib/src/core/raw_operation_data.dart
@@ -13,7 +13,7 @@ class RawOperationData {
Map<String, dynamic> variables,
String operationName,
}) : _operationName = operationName,
- this.variables = SplayTreeMap<String, dynamic>.of(
+ variables = SplayTreeMap<String, dynamic>.of(
variables ?? const <String, dynamic>{},
);

MODIFY
lib/src/socket_client.dart
lib/src/socket_client.dart
@@ -86,7 +86,9 @@ class SocketClient {
///
/// If this instance is disposed, this method does nothing.
Future<void> _connect() async {
- if (_connectionStateController.isClosed) return;
+ if (_connectionStateController.isClosed) {
+ return;
+ }
_connectionStateController.value = SocketConnectionState.CONNECTING;
print('Connecting to websocket: $url...');
@@ -105,15 +107,17 @@ class SocketClient {
.map<GraphQLSocketMessage>(_parseSocketMessage);
if (config.inactivityTimeout != null) {
- _keepAliveSubscription = _connectionKeepAlive
- .timeout(config.inactivityTimeout, onTimeout: (event) {
+ _keepAliveSubscription = _connectionKeepAlive.timeout(
+ config.inactivityTimeout,
+ onTimeout: (EventSink<ConnectionKeepAlive> event) {
print(
"Haven't received keep alive message for ${config.inactivityTimeout.inSeconds} seconds. Disconnecting..");
event.close();
_socket.close(WebSocketStatus.goingAway);
_connectionStateController.value =
SocketConnectionState.NOT_CONNECTED;
- }).listen(null);
+ },
+ ).listen(null);
}
_messageSubscription = _messageStream.listen(
@@ -139,7 +143,9 @@ class SocketClient {
_keepAliveSubscription?.cancel();
_messageSubscription?.cancel();
- if (_connectionStateController.isClosed) return;
+ if (_connectionStateController.isClosed) {
+ return;
+ }
if (_connectionStateController.value != SocketConnectionState.NOT_CONNECTED)
_connectionStateController.value = SocketConnectionState.NOT_CONNECTED;
@@ -149,9 +155,12 @@ class SocketClient {
print(
'Scheduling to connect in ${config.delayBetweenReconnectionAttempts.inSeconds} seconds...');
- _reconnectTimer = Timer(config.delayBetweenReconnectionAttempts, () {
+ _reconnectTimer = Timer(
+ config.delayBetweenReconnectionAttempts,
+ () {
_connect();
- });
+ },
+ );
} else {
Timer.run(() => _connect());
}
@@ -238,35 +247,51 @@ class SocketClient {
.take(1);
final Observable<SocketConnectionState> waitForConnectedState = addTimeout
- ? waitForConnectedStateWithoutTimeout
- .timeout(config.queryAndMutationTimeout, onTimeout: (e) {
+ ? waitForConnectedStateWithoutTimeout.timeout(
+ config.queryAndMutationTimeout,
+ onTimeout: (EventSink<SocketConnectionState> event) {
print('Connection timed out.');
response.addError(TimeoutException('Connection timed out.'));
- e.close();
+ event.close();
response.close();
- })
+ },
+ )
: waitForConnectedStateWithoutTimeout;
sub = waitForConnectedState.listen((_) {
final Stream<GraphQLSocketMessage> dataErrorComplete =
- _messageStream.where((GraphQLSocketMessage message) {
- if (message is SubscriptionData) return message.id == id;
- if (message is SubscriptionError) return message.id == id;
- if (message is SubscriptionComplete) return message.id == id;
+ _messageStream.where(
+ (GraphQLSocketMessage message) {
+ if (message is SubscriptionData) {
+ return message.id == id;
+ }
+
+ if (message is SubscriptionError) {
+ return message.id == id;
+ }
+
+ if (message is SubscriptionComplete) {
+ return message.id == id;
+ }
+
return false;
- }).takeWhile((_) => !response.isClosed);
+ },
+ ).takeWhile((_) => !response.isClosed);
final Stream<GraphQLSocketMessage> subscriptionComplete = addTimeout
? dataErrorComplete
.where((GraphQLSocketMessage message) =>
message is SubscriptionComplete)
.take(1)
- .timeout(config.queryAndMutationTimeout, onTimeout: (e) {
+ .timeout(
+ config.queryAndMutationTimeout,
+ onTimeout: (EventSink<GraphQLSocketMessage> event) {
print('Request timed out.');
response.addError(TimeoutException('Request timed out.'));
- e.close();
+ event.close();
response.close();
- })
+ },
+ )
: dataErrorComplete
.where((GraphQLSocketMessage message) =>
message is SubscriptionComplete)

fix(analyze): Fix the analizer issues