From e68a512a3bee4330ca5c1142d8da1b0553fb8b9d Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 1 Feb 2021 13:58:45 +0530 Subject: [PATCH] Fix analyzer warnings Signed-off-by: Sahil Kumar --- packages/dart_client/lib/src/client.dart | 11 ++--- packages/dart_client/pubspec.yaml | 2 +- .../example/lib/advanced_options_page.dart | 11 ----- .../example/lib/choose_user_page.dart | 6 --- .../flutter_widgets/example/lib/main.dart | 4 -- .../example/lib/notifications_service.dart | 44 ------------------- packages/flutter_widgets/pubspec.yaml | 3 +- .../stream_chat_flutter_core/pubspec.yaml | 1 + 8 files changed, 9 insertions(+), 73 deletions(-) diff --git a/packages/dart_client/lib/src/client.dart b/packages/dart_client/lib/src/client.dart index 381d1cd6..67b3f444 100644 --- a/packages/dart_client/lib/src/client.dart +++ b/packages/dart_client/lib/src/client.dart @@ -8,7 +8,6 @@ import 'package:logging/logging.dart'; import 'package:rxdart/rxdart.dart'; import 'package:stream_chat/src/api/retry_policy.dart'; import 'package:stream_chat/src/event_type.dart'; -import 'package:stream_chat/src/models/channel_model.dart'; import 'package:stream_chat/src/models/own_user.dart'; import 'package:stream_chat/version.dart'; import 'package:uuid/uuid.dart'; @@ -460,10 +459,12 @@ class Client { _connectionStatusHandler = (ConnectionStatus status) async { _wsConnectionStatus = status; - handleEvent(Event( - type: EventType.connectionChanged, - online: status == ConnectionStatus.connected, - )); + handleEvent( + Event( + type: EventType.connectionChanged, + online: status == ConnectionStatus.connected, + ), + ); if (status == ConnectionStatus.connected && state.channels?.isNotEmpty == true) { diff --git a/packages/dart_client/pubspec.yaml b/packages/dart_client/pubspec.yaml index 9cdc130f..e9036a09 100644 --- a/packages/dart_client/pubspec.yaml +++ b/packages/dart_client/pubspec.yaml @@ -17,10 +17,10 @@ dependencies: async: ^2.4.1 rxdart: ^0.24.1 collection: ^1.14.12 - pedantic: ^1.9.2 dev_dependencies: build_runner: ^1.10.0 json_serializable: ^3.3.0 test: ^1.15.7 mockito: ^4.1.1 + pedantic: ^1.9.2 diff --git a/packages/flutter_widgets/example/lib/advanced_options_page.dart b/packages/flutter_widgets/example/lib/advanced_options_page.dart index 0b55212c..35e2af7f 100644 --- a/packages/flutter_widgets/example/lib/advanced_options_page.dart +++ b/packages/flutter_widgets/example/lib/advanced_options_page.dart @@ -1,19 +1,12 @@ -import 'dart:io'; - -import 'package:example/routes/app_routes.dart'; import 'package:example/routes/routes.dart'; import 'package:example/stream_version.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -import 'package:stream_chat_persistence/stream_chat_persistence.dart'; -import 'package:streaming_shared_preferences/streaming_shared_preferences.dart'; import 'choose_user_page.dart'; import 'main.dart'; -import 'notifications_service.dart'; class AdvancedOptionsPage extends StatefulWidget { @override @@ -287,10 +280,6 @@ class _AdvancedOptionsPageState extends State { userToken, ); - if (!kIsWeb) { - initNotifications(client); - } - final secureStorage = FlutterSecureStorage(); secureStorage.write( key: kStreamApiKey, diff --git a/packages/flutter_widgets/example/lib/choose_user_page.dart b/packages/flutter_widgets/example/lib/choose_user_page.dart index 8e36e748..02852c64 100644 --- a/packages/flutter_widgets/example/lib/choose_user_page.dart +++ b/packages/flutter_widgets/example/lib/choose_user_page.dart @@ -1,11 +1,9 @@ import 'package:example/stream_version.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -import 'notifications_service.dart'; import 'routes/routes.dart'; const kStreamApiKey = 'STREAM_API_KEY'; @@ -187,10 +185,6 @@ class ChooseUserPage extends StatelessWidget { key: kStreamToken, value: token, ); - - if (!kIsWeb) { - initNotifications(client); - } Navigator.pushNamedAndRemoveUntil( context, Routes.HOME, diff --git a/packages/flutter_widgets/example/lib/main.dart b/packages/flutter_widgets/example/lib/main.dart index a44a8692..93c7b082 100644 --- a/packages/flutter_widgets/example/lib/main.dart +++ b/packages/flutter_widgets/example/lib/main.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:io'; import 'package:example/chat_info_screen.dart'; import 'package:example/choose_user_page.dart'; @@ -41,9 +40,6 @@ void main() async { User(id: userId), token, ); - if (!kIsWeb) { - initNotifications(client); - } } runApp(MyApp(client)); diff --git a/packages/flutter_widgets/example/lib/notifications_service.dart b/packages/flutter_widgets/example/lib/notifications_service.dart index e74a2a5a..246923df 100644 --- a/packages/flutter_widgets/example/lib/notifications_service.dart +++ b/packages/flutter_widgets/example/lib/notifications_service.dart @@ -1,8 +1,3 @@ -import 'dart:io'; - -import 'package:example/main.dart'; -import 'package:firebase_messaging/firebase_messaging.dart'; -import 'package:flutter_apns/flutter_apns.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart' hide Message; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -34,42 +29,3 @@ void showLocalNotification(Event event) async { ), ); } - -Future backgroundHandler(Map notification) async { - print('new notification ${notification}'); - // final messageId = notification['data']['id']; - // - // final notificationData = await NotificationService.getAndStoreMessage( - // messageId: messageId, - // storeMessageHandler: (messageResponse) { - // return chatPersistentClient.updateChannelState( - // ChannelState( - // messages: [messageResponse.message], - // channel: messageResponse.channel, - // ), - // ); - // }, - // ); - // - // showLocalNotification( - // notificationData.message, - // notificationData.channel, - // ); -} - -void initNotifications(Client client) { - final connector = createPushConnector(); - connector.configure( - onBackgroundMessage: backgroundHandler, - ); - - connector.requestNotificationPermissions(); - connector.token.addListener(() { - if (connector.token.value != null) { - client.addDevice( - connector.token.value, - Platform.isAndroid ? PushProvider.firebase : PushProvider.apn, - ); - } - }); -} diff --git a/packages/flutter_widgets/pubspec.yaml b/packages/flutter_widgets/pubspec.yaml index 9321f992..af2e39f4 100644 --- a/packages/flutter_widgets/pubspec.yaml +++ b/packages/flutter_widgets/pubspec.yaml @@ -58,8 +58,7 @@ flutter: - animations/ dev_dependencies: - flutter_test: sdk: flutter mockito: ^4.1.3 - pedantic: ^1.9.2 + pedantic: ^1.9.2 \ No newline at end of file diff --git a/packages/stream_chat_flutter_core/pubspec.yaml b/packages/stream_chat_flutter_core/pubspec.yaml index 61c3528e..6dbde76e 100644 --- a/packages/stream_chat_flutter_core/pubspec.yaml +++ b/packages/stream_chat_flutter_core/pubspec.yaml @@ -20,4 +20,5 @@ dev_dependencies: flutter_test: sdk: flutter fake_async: ^1.1.0 + pedantic: ^1.9.2 \ No newline at end of file