diff --git a/lib/dekstop_services/desktop_image_picker.dart b/lib/dekstop_services/desktop_image_picker.dart index a2ca7255..00fe30fb 100644 --- a/lib/dekstop_services/desktop_image_picker.dart +++ b/lib/dekstop_services/desktop_image_picker.dart @@ -8,9 +8,10 @@ Future?> desktopImagePicker() async { final XTypeGroup typeGroup = XTypeGroup(); final List files = await openFiles(acceptedTypeGroups: [typeGroup]); - if (files == null) { - return null; - } + // files can't be null + // if (files!=null) { + // return null; + // } await Future.forEach(files, (XFile f) async { selectedFiles.add( diff --git a/lib/desktop_routes/desktop_routes.dart b/lib/desktop_routes/desktop_routes.dart index bb99ea49..61b4dd11 100644 --- a/lib/desktop_routes/desktop_routes.dart +++ b/lib/desktop_routes/desktop_routes.dart @@ -75,8 +75,8 @@ class DesktopSetupRoutes { DesktopRoutes.DESKTOP_EMPTY_TRUSTED_SENDER: (context) => DesktopEmptySender(), DesktopRoutes.DESKTOP_GROUP: (context) { - Map? args = - ModalRoute.of(context)!.settings.arguments as Map?; + // Map? args = + // ModalRoute.of(context)!.settings.arguments as Map?; DesktopGroupSetupRoutes.setExitFunction(() { DesktopSetupRoutes.nested_pop(); }); diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_contacts_custom_list_tile.dart b/lib/desktop_screens/desktop_common_widgets/desktop_contacts_custom_list_tile.dart index d7d3c06c..0bd10348 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_contacts_custom_list_tile.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_contacts_custom_list_tile.dart @@ -39,7 +39,9 @@ class DesktopContactsCustomListTile extends StatelessWidget { )), trailing: IconButton( onPressed: () {}, - icon: (false) ? Icon(Icons.close) : Icon(Icons.add), + icon: Icon(Icons.add), + // condition is always false + // (false) ? Icon(Icons.close) : Icon(Icons.add), ), ); } diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_custom_input_field.dart b/lib/desktop_screens/desktop_common_widgets/desktop_custom_input_field.dart index 39ffa1ab..78ae8db1 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_custom_input_field.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_custom_input_field.dart @@ -31,9 +31,11 @@ class DesktopCustomInputField extends StatelessWidget { @override Widget build(BuildContext context) { textController = TextEditingController.fromValue(TextEditingValue( - text: initialValue != null ? initialValue : '', + // initalValue can't be null + text: initialValue, selection: TextSelection.collapsed( - offset: initialValue != null ? initialValue.length : -1))); + // initialValue can't be null + offset: initialValue.length))); return Container( width: width.toWidth, height: height, diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_custom_vertical_tile.dart b/lib/desktop_screens/desktop_common_widgets/desktop_custom_vertical_tile.dart index fe23d663..9f8658f9 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_custom_vertical_tile.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_custom_vertical_tile.dart @@ -33,9 +33,7 @@ Widget customPersonVerticalTile( right: 0, child: InkWell( onTap: () { - if (onCancel != null) { - onCancel(); - } + onCancel(); }, child: isCancelIcon ? Icon(Icons.cancel) : SizedBox(), ), diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_header.dart b/lib/desktop_screens/desktop_common_widgets/desktop_header.dart index d26b9a35..36e287d3 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_header.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_header.dart @@ -6,15 +6,15 @@ import 'package:flutter/material.dart'; class DesktopHeader extends StatelessWidget { final String? title; final ValueChanged? onFilter; - List? actions; - List options = [ + final List? actions; + final List options = [ 'By type', 'By name', 'By size', 'By date', 'add-btn' ]; - bool showBackIcon, isTitleCentered; + final bool showBackIcon, isTitleCentered; DesktopHeader( {this.title, this.showBackIcon = true, diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_selected_contacts.dart b/lib/desktop_screens/desktop_common_widgets/desktop_selected_contacts.dart index 537df024..e45d2da7 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_selected_contacts.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_selected_contacts.dart @@ -7,8 +7,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class DesktopSelectedContacts extends StatefulWidget { - ValueChanged onChange; - bool showCancelIcon; + final ValueChanged onChange; + final bool showCancelIcon; DesktopSelectedContacts(this.onChange, {this.showCancelIcon = false}); @override diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_selected_files.dart b/lib/desktop_screens/desktop_common_widgets/desktop_selected_files.dart index e37aeec5..9071ae78 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_selected_files.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_selected_files.dart @@ -10,7 +10,7 @@ import 'package:provider/provider.dart'; import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; class DesktopSelectedFiles extends StatefulWidget { - ValueChanged onChange; + final ValueChanged onChange; final bool showCancelIcon; DesktopSelectedFiles(this.onChange, {this.showCancelIcon = true}); @override @@ -18,15 +18,16 @@ class DesktopSelectedFiles extends StatefulWidget { } class _DesktopSelectedFilesState extends State { - FileTransferProvider? _filePickerProvider; + // late FileTransferProvider? _filePickerProvider; late WelcomeScreenProvider welcomeScreenProvider; @override void initState() { welcomeScreenProvider = Provider.of( NavService.navKey.currentContext!, listen: false); - _filePickerProvider = - Provider.of(context, listen: false); + // _filePickerProvider isn't used + // _filePickerProvider = + // Provider.of(context, listen: false); super.initState(); } diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_switch_atsign.dart b/lib/desktop_screens/desktop_common_widgets/desktop_switch_atsign.dart index f1a59c66..c7d3f2e8 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_switch_atsign.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_switch_atsign.dart @@ -12,7 +12,7 @@ import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; import 'package:flutter/material.dart'; class DesktopSwitchAtsign extends StatefulWidget { - String atsign; + final String atsign; DesktopSwitchAtsign({Key? key, required this.atsign}) : super(key: key); @override @@ -91,7 +91,7 @@ class _DesktopSwitchAtsignState extends State { ), ), SizedBox(height: 5), - (_name != null && _name != '') + (_name != '') ? SizedBox( width: 180, child: Text( diff --git a/lib/desktop_screens/desktop_history/desktop_history.dart b/lib/desktop_screens/desktop_history/desktop_history.dart index 2770856b..fad986c5 100644 --- a/lib/desktop_screens/desktop_history/desktop_history.dart +++ b/lib/desktop_screens/desktop_history/desktop_history.dart @@ -1,4 +1,3 @@ -import 'package:at_common_flutter/widgets/custom_input_field.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/desktop_screens/desktop_history/widgets/desktop_received_file_details.dart'; import 'package:atsign_atmosphere_pro/desktop_screens/desktop_history/widgets/desktop_received_file_list_tile.dart'; @@ -17,7 +16,7 @@ import 'package:provider/provider.dart'; class DesktopHistoryScreen extends StatefulWidget { final int tabIndex; - Key? key; + final Key? key; DesktopHistoryScreen({this.tabIndex = 0, this.key}); @override _DesktopHistoryScreenState createState() => _DesktopHistoryScreenState(); @@ -82,9 +81,10 @@ class _DesktopHistoryScreenState extends State @override Widget build(BuildContext context) { - if (historyProvider == null) { - historyProvider = Provider.of(context); - } + // historyProvider can't be null + // if (historyProvider == null) { + // historyProvider = Provider.of(context); + // } SizeConfig().init(context); return Scaffold( backgroundColor: ColorConstants.scaffoldColor, diff --git a/lib/desktop_screens/desktop_history/widgets/desktop_sent_file_details.dart b/lib/desktop_screens/desktop_history/widgets/desktop_sent_file_details.dart index d2d09953..288697ba 100644 --- a/lib/desktop_screens/desktop_history/widgets/desktop_sent_file_details.dart +++ b/lib/desktop_screens/desktop_history/widgets/desktop_sent_file_details.dart @@ -17,7 +17,7 @@ import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; class DesktopSentFileDetails extends StatefulWidget { final FileHistory? selectedFileData; - Key? key; + final Key? key; DesktopSentFileDetails({this.key, this.selectedFileData}); @override diff --git a/lib/desktop_screens/desktop_my_files/widgets/desktop_recent.dart b/lib/desktop_screens/desktop_my_files/widgets/desktop_recent.dart index 49ab4dc2..7a67c41c 100644 --- a/lib/desktop_screens/desktop_my_files/widgets/desktop_recent.dart +++ b/lib/desktop_screens/desktop_my_files/widgets/desktop_recent.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:atsign_atmosphere_pro/desktop_screens/desktop_my_files/widgets/desktop_file_card.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_handler.dart'; import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; import 'package:atsign_atmosphere_pro/view_models/history_provider.dart'; import 'package:flutter/material.dart'; diff --git a/lib/desktop_screens/desktop_welcome_screen/desktop_welcome_screen.dart b/lib/desktop_screens/desktop_welcome_screen/desktop_welcome_screen.dart index 369437c4..8cf3fce2 100644 --- a/lib/desktop_screens/desktop_welcome_screen/desktop_welcome_screen.dart +++ b/lib/desktop_screens/desktop_welcome_screen/desktop_welcome_screen.dart @@ -19,12 +19,9 @@ import 'package:atsign_atmosphere_pro/view_models/switch_atsign_provider.dart'; import 'package:flutter/material.dart'; import 'package:at_common_flutter/services/size_config.dart'; import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/widgets.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_handler.dart'; import 'package:provider/provider.dart'; import 'package:atsign_atmosphere_pro/utils/constants.dart'; -import 'package:url_launcher/url_launcher_string.dart'; import 'package:url_launcher/url_launcher.dart'; class DesktopWelcomeScreenStart extends StatefulWidget { diff --git a/lib/desktop_screens/desktop_welcome_screen/widgets/welcome_screen_home.dart b/lib/desktop_screens/desktop_welcome_screen/widgets/welcome_screen_home.dart index a9a6d04c..571052d1 100644 --- a/lib/desktop_screens/desktop_welcome_screen/widgets/welcome_screen_home.dart +++ b/lib/desktop_screens/desktop_welcome_screen/widgets/welcome_screen_home.dart @@ -2,12 +2,10 @@ import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_contacts_group_flutter/screens/group_contact_view/group_contact_view.dart'; import 'package:at_contacts_group_flutter/services/group_service.dart'; import 'package:atsign_atmosphere_pro/dekstop_services/desktop_image_picker.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_toast.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/triple_dot_loading.dart'; import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; import 'package:atsign_atmosphere_pro/services/snackbar_service.dart'; -import 'package:atsign_atmosphere_pro/view_models/base_model.dart'; import 'package:atsign_atmosphere_pro/view_models/file_transfer_provider.dart'; import 'package:atsign_atmosphere_pro/view_models/welcome_screen_view_model.dart'; import 'package:atsign_atmosphere_pro/services/backend_service.dart'; @@ -85,10 +83,11 @@ class _WelcomeScreenHomeState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - 'Welcome ' + - (AtClientManager.getInstance().atClient != null - ? '${AtClientManager.getInstance().atClient.getCurrentAtSign()}' - : ''), + 'Welcome ${AtClientManager.getInstance().atClient.getCurrentAtSign()}', + // AtClientManager.getInstance().atClient can't be null + // + (AtClientManager.getInstance().atClient != null + // ? '${AtClientManager.getInstance().atClient.getCurrentAtSign()}' + // : ''), style: CustomTextStyles.desktopBlackPlayfairDisplay26, ), SizedBox( @@ -121,8 +120,7 @@ class _WelcomeScreenHomeState extends State { SizedBox( height: 20.toHeight, ), - (_welcomeScreenProvider.selectedContacts != null && - _welcomeScreenProvider.selectedContacts.isNotEmpty && + (_welcomeScreenProvider.selectedContacts.isNotEmpty && _filePickerProvider.selectedFiles.isNotEmpty) ? Container( color: Colors.white, @@ -178,8 +176,7 @@ class _WelcomeScreenHomeState extends State { ) : SizedBox(), SizedBox( - height: (_welcomeScreenProvider.selectedContacts != null && - _welcomeScreenProvider.selectedContacts.isNotEmpty && + height: (_welcomeScreenProvider.selectedContacts.isNotEmpty && _filePickerProvider.selectedFiles.isNotEmpty) ? 10.toHeight : 0, diff --git a/lib/desktop_screens/trusted_sender/desktop_trusted_sender.dart b/lib/desktop_screens/trusted_sender/desktop_trusted_sender.dart index 6962c08c..562d6522 100644 --- a/lib/desktop_screens/trusted_sender/desktop_trusted_sender.dart +++ b/lib/desktop_screens/trusted_sender/desktop_trusted_sender.dart @@ -1,6 +1,4 @@ import 'package:at_contacts_group_flutter/screens/group_contact_view/group_contact_view.dart'; -import 'package:atsign_atmosphere_pro/desktop_routes/desktop_route_names.dart'; -import 'package:atsign_atmosphere_pro/desktop_routes/desktop_routes.dart'; import 'package:atsign_atmosphere_pro/desktop_screens/desktop_common_widgets/dektop_custom_person_tile.dart'; import 'package:atsign_atmosphere_pro/desktop_screens/desktop_common_widgets/desktop_custom_input_field.dart'; import 'package:atsign_atmosphere_pro/desktop_screens/desktop_common_widgets/desktop_header.dart'; diff --git a/lib/main.dart b/lib/main.dart index 597427ab..3bec891d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:at_utils/at_logger.dart'; import 'package:desktop_window/desktop_window.dart'; import 'app.dart'; import 'dart:io'; diff --git a/lib/routes/routes.dart b/lib/routes/routes.dart index cca75c11..f6589b2b 100644 --- a/lib/routes/routes.dart +++ b/lib/routes/routes.dart @@ -43,8 +43,9 @@ class SetupRoutes { ); }, Routes.GROUPS: (context) { - Map? args = - ModalRoute.of(context)!.settings.arguments as Map?; + // args isn't used + // Map? args = + // ModalRoute.of(context)!.settings.arguments as Map?; return GroupList(); }, Routes.TRUSTED_CONTACTS: (context) => TrustedContacts(), diff --git a/lib/screens/common_widgets/app_bar.dart b/lib/screens/common_widgets/app_bar.dart index 5ff1f394..510b0c35 100644 --- a/lib/screens/common_widgets/app_bar.dart +++ b/lib/screens/common_widgets/app_bar.dart @@ -9,7 +9,6 @@ import 'dart:io'; import 'package:at_contacts_flutter/screens/contacts_screen.dart'; import 'package:at_contacts_flutter/widgets/add_contacts_dialog.dart'; -import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/services/backend_service.dart'; import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; import 'package:at_common_flutter/services/size_config.dart'; @@ -18,7 +17,6 @@ import 'package:atsign_atmosphere_pro/utils/images.dart'; import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; import 'package:atsign_atmosphere_pro/view_models/file_download_checker.dart'; -import 'package:atsign_atmosphere_pro/view_models/history_provider.dart'; import 'package:atsign_atmosphere_pro/view_models/trusted_sender_view_model.dart'; import 'package:filesystem_picker/filesystem_picker.dart'; import 'package:flutter/material.dart'; @@ -157,8 +155,8 @@ class _CustomAppBarState extends State { BackendService.getInstance() .atClientPreference .downloadPath!; - if (await canLaunch(url)) { - await launch(url); + if (await canLaunchUrl(Uri.parse(url))) { + await launchUrl(Uri.parse(url)); } else { throw 'Could not launch $url'; } diff --git a/lib/screens/common_widgets/contact_initial.dart b/lib/screens/common_widgets/contact_initial.dart index f09501c6..5807ae92 100644 --- a/lib/screens/common_widgets/contact_initial.dart +++ b/lib/screens/common_widgets/contact_initial.dart @@ -6,8 +6,8 @@ import 'package:at_common_flutter/services/size_config.dart'; class ContactInitial extends StatelessWidget { final double? size, maxSize, minSize; final String? initials; - int? index; - Color? background; + final int? index; + final Color? background; ContactInitial( {Key? key, @@ -20,10 +20,11 @@ class ContactInitial extends StatelessWidget { : super(key: key); @override Widget build(BuildContext context) { + int? _index = index; if (initials!.length < 3) { - index = initials!.length; + _index = initials!.length; } else { - index = 3; + _index = 3; } return Container( @@ -37,7 +38,7 @@ class ContactInitial extends StatelessWidget { ), child: Center( child: Text( - initials!.substring((index == 1) ? 0 : 1, index).toUpperCase(), + initials!.substring((_index == 1) ? 0 : 1, _index).toUpperCase(), style: CustomTextStyles.whiteBold(size: (size! ~/ 3)), ), ), diff --git a/lib/screens/common_widgets/custom_popup_route.dart b/lib/screens/common_widgets/custom_popup_route.dart index a54b2cee..477b6e05 100644 --- a/lib/screens/common_widgets/custom_popup_route.dart +++ b/lib/screens/common_widgets/custom_popup_route.dart @@ -9,8 +9,7 @@ class CustomPopupRoutes extends PopupRoute { Duration transitionDuration = const Duration(milliseconds: 200), RouteTransitionsBuilder? transitionBuilder, RouteSettings? settings, - }) : assert(barrierDismissible != null), - _pageBuilder = pageBuilder, + }) : _pageBuilder = pageBuilder, _barrierDismissible = barrierDismissible, _barrierLabel = barrierLabel, _barrierColor = barrierColor, diff --git a/lib/screens/common_widgets/error_screen.dart b/lib/screens/common_widgets/error_screen.dart index 0d129038..66d37129 100644 --- a/lib/screens/common_widgets/error_screen.dart +++ b/lib/screens/common_widgets/error_screen.dart @@ -1,4 +1,3 @@ -import 'package:at_common_flutter/at_common_flutter.dart'; import 'package:atsign_atmosphere_pro/utils/images.dart'; import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; import 'package:flutter/material.dart'; diff --git a/lib/screens/common_widgets/history_app_bar.dart b/lib/screens/common_widgets/history_app_bar.dart index 4cdfb20d..870aaceb 100644 --- a/lib/screens/common_widgets/history_app_bar.dart +++ b/lib/screens/common_widgets/history_app_bar.dart @@ -147,8 +147,8 @@ class _HistoryAppBarState extends State { } else { String url = 'shareddocuments://' + BackendService.getInstance().atClientPreference.downloadPath!; - if (await canLaunch(url)) { - await launch(url); + if (await canLaunchUrl(Uri.parse(url))) { + await launchUrl(Uri.parse(url)); } else { throw 'Could not launch $url'; } diff --git a/lib/screens/common_widgets/labelled_circular_progress.dart b/lib/screens/common_widgets/labelled_circular_progress.dart index 19db0e0c..3256b0ba 100644 --- a/lib/screens/common_widgets/labelled_circular_progress.dart +++ b/lib/screens/common_widgets/labelled_circular_progress.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import '../../utils/colors.dart'; class LabelledCircularProgressIndicator extends StatelessWidget { - double? value; + final double? value; LabelledCircularProgressIndicator({this.value}); @override Widget build(BuildContext context) { diff --git a/lib/screens/common_widgets/person_vertical_tile.dart b/lib/screens/common_widgets/person_vertical_tile.dart index 76a39cfd..781e1e10 100644 --- a/lib/screens/common_widgets/person_vertical_tile.dart +++ b/lib/screens/common_widgets/person_vertical_tile.dart @@ -4,7 +4,6 @@ import 'package:at_contacts_flutter/at_contacts_flutter.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/triple_dot_loading.dart'; -import 'package:at_common_flutter/services/size_config.dart'; import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; import 'package:atsign_atmosphere_pro/services/snackbar_service.dart'; diff --git a/lib/screens/common_widgets/side_bar.dart b/lib/screens/common_widgets/side_bar.dart index 08d5d2e1..d9ebf69a 100644 --- a/lib/screens/common_widgets/side_bar.dart +++ b/lib/screens/common_widgets/side_bar.dart @@ -1,17 +1,13 @@ -import 'dart:io'; import 'dart:typed_data'; import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_contact/at_contact.dart'; import 'package:at_contacts_flutter/utils/init_contacts_service.dart'; -import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/routes/route_names.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; import 'package:atsign_atmosphere_pro/view_models/file_download_checker.dart'; -import 'package:atsign_atmosphere_pro/view_models/history_provider.dart'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:atsign_atmosphere_pro/routes/route_names.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/side_bar_backup_item.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/side_bar_list_item.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/switch_at_sign.dart'; @@ -24,7 +20,6 @@ import 'package:atsign_atmosphere_pro/utils/images.dart'; import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; import 'package:atsign_atmosphere_pro/view_models/welcome_screen_view_model.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:package_info_plus/package_info_plus.dart'; diff --git a/lib/screens/common_widgets/side_bar_list_item.dart b/lib/screens/common_widgets/side_bar_list_item.dart index 6846334f..94b7da54 100644 --- a/lib/screens/common_widgets/side_bar_list_item.dart +++ b/lib/screens/common_widgets/side_bar_list_item.dart @@ -2,7 +2,6 @@ import 'package:at_common_flutter/services/size_config.dart'; import 'package:atsign_atmosphere_pro/utils/colors.dart'; import 'package:atsign_atmosphere_pro/view_models/welcome_screen_view_model.dart'; import 'package:flutter/material.dart'; -import 'package:url_launcher/url_launcher.dart'; class SideBarItem extends StatelessWidget { final String? image; @@ -12,7 +11,7 @@ class SideBarItem extends StatelessWidget { final bool showIconOnly, isDesktop; final WelcomeScreenProvider _welcomeScreenProvider = WelcomeScreenProvider(); final Color displayColor; - bool isScale; + final bool isScale; final bool showNotificationDot; SideBarItem( {Key? key, @@ -28,8 +27,10 @@ class SideBarItem extends StatelessWidget { : super(key: key); @override Widget build(BuildContext context) { + // since all arguments should be final in stateless widget + bool _isScale = isScale; if (SizeConfig().isMobile(context)) { - isScale = false; + _isScale = false; } return InkWell( @@ -49,7 +50,7 @@ class SideBarItem extends StatelessWidget { Container( margin: EdgeInsets.only(right: isDesktop ? 20 : 10), child: Transform.scale( - scale: isScale ? 1.2 : 1, + scale: _isScale ? 1.2 : 1, child: Image.asset( image!, height: SizeConfig().isTablet(context) ? 24 : 22.toHeight, @@ -92,15 +93,16 @@ class SideBarItem extends StatelessWidget { ); } - Future _launchInBrowser(String url) async { - if (await canLaunch(url)) { - await launch( - url, - forceSafariVC: false, - forceWebView: false, - ); - } else { - throw 'Could not launch $url'; - } - } + // this function isn't used + // Future _launchInBrowser(String url) async { + // if (await canLaunchUrl(Uri.parse(url))) { + // await launchUrl( + // Uri.parse(url), + // // forceSafariVC: false, + // // forceWebView: false, + // ); + // } else { + // throw 'Could not launch $url'; + // } + // } } diff --git a/lib/screens/common_widgets/switch_at_sign.dart b/lib/screens/common_widgets/switch_at_sign.dart index 44e30512..d491260c 100644 --- a/lib/screens/common_widgets/switch_at_sign.dart +++ b/lib/screens/common_widgets/switch_at_sign.dart @@ -71,8 +71,8 @@ class _AtSignBottomSheetState extends State { .checkToOnboard( atSign: widget.atSignList![index]); - - Navigator.pop(context); + + // Navigator.pop(context); // Navigator.pop(context); }, child: Padding( diff --git a/lib/screens/common_widgets/triple_dot_loading.dart b/lib/screens/common_widgets/triple_dot_loading.dart index 69a72bf2..117c26da 100644 --- a/lib/screens/common_widgets/triple_dot_loading.dart +++ b/lib/screens/common_widgets/triple_dot_loading.dart @@ -1,7 +1,6 @@ import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; class TypingIndicator extends StatefulWidget { const TypingIndicator({ diff --git a/lib/screens/history/history_screen.dart b/lib/screens/history/history_screen.dart index 53364a92..2bba8f82 100644 --- a/lib/screens/history/history_screen.dart +++ b/lib/screens/history/history_screen.dart @@ -1,5 +1,4 @@ import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/app_bar.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_handler.dart'; import 'package:atsign_atmosphere_pro/screens/history/widgets/received_file_list_tile.dart'; import 'package:atsign_atmosphere_pro/screens/history/widgets/sent_file_list_tile.dart'; diff --git a/lib/screens/history/widgets/file_recipients.dart b/lib/screens/history/widgets/file_recipients.dart index 836bed9c..8348318b 100644 --- a/lib/screens/history/widgets/file_recipients.dart +++ b/lib/screens/history/widgets/file_recipients.dart @@ -11,7 +11,7 @@ import 'package:provider/provider.dart'; class FileRecipients extends StatefulWidget { final List? filesharedWith; - FileRecipientSection? fileRecipientSection; + final FileRecipientSection? fileRecipientSection; FileRecipients(this.filesharedWith, {this.fileRecipientSection, Key? key}); @override diff --git a/lib/screens/history/widgets/received_file_list_tile.dart b/lib/screens/history/widgets/received_file_list_tile.dart index 4db4d67e..5c0b2d1b 100644 --- a/lib/screens/history/widgets/received_file_list_tile.dart +++ b/lib/screens/history/widgets/received_file_list_tile.dart @@ -16,7 +16,6 @@ import 'package:atsign_atmosphere_pro/services/snackbar_service.dart'; import 'package:atsign_atmosphere_pro/utils/colors.dart'; import 'package:atsign_atmosphere_pro/utils/constants.dart'; import 'package:atsign_atmosphere_pro/utils/file_types.dart'; -import 'package:atsign_atmosphere_pro/utils/images.dart'; import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; import 'package:atsign_atmosphere_pro/view_models/file_progress_provider.dart'; diff --git a/lib/screens/my_files/widgets/downloads_folders.dart b/lib/screens/my_files/widgets/downloads_folders.dart index fe1d387e..4a254049 100644 --- a/lib/screens/my_files/widgets/downloads_folders.dart +++ b/lib/screens/my_files/widgets/downloads_folders.dart @@ -24,8 +24,8 @@ Future openDownloadsFolder(BuildContext context) async { } else { String url = 'shareddocuments://' + BackendService.getInstance().atClientPreference.downloadPath!; - if (await canLaunch(url)) { - await launch(url); + if (await canLaunchUrl(Uri.parse(url))) { + await launchUrl(Uri.parse(url)); } else { throw 'Could not launch $url'; } diff --git a/lib/screens/trusted_contacts/trusted_contacts.dart b/lib/screens/trusted_contacts/trusted_contacts.dart index 0cc99ab3..b62bc028 100644 --- a/lib/screens/trusted_contacts/trusted_contacts.dart +++ b/lib/screens/trusted_contacts/trusted_contacts.dart @@ -5,7 +5,6 @@ import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; import 'package:atsign_atmosphere_pro/utils/text_strings.dart' as pro_text_strings; -import 'package:atsign_atmosphere_pro/utils/colors.dart' as pro_color_constants; import 'package:atsign_atmosphere_pro/screens/common_widgets/app_bar.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_button.dart'; diff --git a/lib/screens/trusted_contacts/widgets/remove_trusted_contact_dialog.dart b/lib/screens/trusted_contacts/widgets/remove_trusted_contact_dialog.dart index 13c067e0..d44b4ff1 100644 --- a/lib/screens/trusted_contacts/widgets/remove_trusted_contact_dialog.dart +++ b/lib/screens/trusted_contacts/widgets/remove_trusted_contact_dialog.dart @@ -3,8 +3,6 @@ import 'dart:typed_data'; import 'package:at_contact/at_contact.dart'; import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; import 'package:at_contacts_flutter/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart' - as pro_text_strings; import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_button.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_circle_avatar.dart'; diff --git a/lib/screens/welcome_screen/widgets/overlapping_contacts.dart b/lib/screens/welcome_screen/widgets/overlapping_contacts.dart index e638866f..c4c71ad1 100644 --- a/lib/screens/welcome_screen/widgets/overlapping_contacts.dart +++ b/lib/screens/welcome_screen/widgets/overlapping_contacts.dart @@ -1,6 +1,5 @@ import 'dart:typed_data'; -import 'package:at_contact/at_contact.dart'; /// This is a custom widget to display the selected contacts /// in a row with overlapping profile pictures diff --git a/lib/screens/welcome_screen/widgets/select_file_widget.dart b/lib/screens/welcome_screen/widgets/select_file_widget.dart index c87d7d09..c8c96ef8 100644 --- a/lib/screens/welcome_screen/widgets/select_file_widget.dart +++ b/lib/screens/welcome_screen/widgets/select_file_widget.dart @@ -1,5 +1,4 @@ import 'dart:typed_data'; -import 'package:at_common_flutter/widgets/custom_input_field.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/error_dialog.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_callback.dart'; import 'package:at_common_flutter/services/size_config.dart'; diff --git a/lib/screens/welcome_screen/widgets/welcome_sceen_home.dart b/lib/screens/welcome_screen/widgets/welcome_sceen_home.dart index 3deda2b9..626fa916 100644 --- a/lib/screens/welcome_screen/widgets/welcome_sceen_home.dart +++ b/lib/screens/welcome_screen/widgets/welcome_sceen_home.dart @@ -182,16 +182,12 @@ class _WelcomeScreenHomeState extends State { ), SizedBox( height: (_welcomeScreenProvider - .selectedContacts != - null && - _welcomeScreenProvider .selectedContacts.isNotEmpty && filePickerModel.selectedFiles.isNotEmpty) ? 20.toHeight : 60.toHeight, ), - (_welcomeScreenProvider.selectedContacts != null && - _welcomeScreenProvider + (_welcomeScreenProvider .selectedContacts.isNotEmpty && filePickerModel.selectedFiles.isNotEmpty) ? Container( @@ -269,9 +265,7 @@ class _WelcomeScreenHomeState extends State { SizedBox( height: 30.toHeight, ), - if (_welcomeScreenProvider.selectedContacts != - null && - _welcomeScreenProvider + if (_welcomeScreenProvider .selectedContacts.isNotEmpty && filePickerModel.selectedFiles.isNotEmpty) ...[ Row( diff --git a/lib/services/at_error_dialog.dart b/lib/services/at_error_dialog.dart index 4ea22b74..5e9f7a33 100644 --- a/lib/services/at_error_dialog.dart +++ b/lib/services/at_error_dialog.dart @@ -32,37 +32,26 @@ class AtErrorDialog { switch (error.runtimeType) { case AtClientException: return TextStrings().unableToPerform; - break; case UnAuthenticatedException: return TextStrings().unableToAuthenticate; - break; case NoSuchMethodError: return TextStrings().failedInProcessing; - break; case AtConnectException: return TextStrings().unableToConnectServer; - break; case AtIOException: return TextStrings().unableToPerformRead_Write; - break; case AtServerException: return TextStrings().unableToActivateServer; - break; case SecondaryNotFoundException: return TextStrings().serverIsUnavailable; - break; case SecondaryConnectException: return TextStrings().unableToConnect; - break; case InvalidAtSignException: return TextStrings().invalidAtSign; - break; case String: return error; - break; default: return TextStrings().unknownError; - break; } } } diff --git a/lib/services/backend_service.dart b/lib/services/backend_service.dart index 9822fb65..2dd5a0f8 100644 --- a/lib/services/backend_service.dart +++ b/lib/services/backend_service.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'package:at_commons/at_commons.dart'; import 'package:at_contacts_flutter/services/contact_service.dart'; import 'package:at_contacts_flutter/utils/init_contacts_service.dart'; import 'package:at_contacts_group_flutter/utils/init_group_service.dart'; @@ -34,8 +33,6 @@ import 'package:path_provider/path_provider.dart' as path_provider; import 'package:provider/provider.dart'; import 'navigation_service.dart'; import 'package:at_client/src/service/sync_service.dart'; -import 'package:at_client/src/service/notification_service_impl.dart'; -import 'package:at_client/src/service/notification_service.dart'; import 'package:at_sync_ui_flutter/at_sync_ui_flutter.dart'; class BackendService { @@ -182,7 +179,7 @@ class BackendService { .contains(MixedConstants.FILE_TRANSFER_ACKNOWLEDGEMENT)) { var decryptedMessage = response.value!; - if (decryptedMessage != null && decryptedMessage != '') { + if (decryptedMessage != '') { DownloadAcknowledgement downloadAcknowledgement = DownloadAcknowledgement.fromJson(jsonDecode(decryptedMessage)); @@ -202,7 +199,7 @@ class BackendService { //TODO: only for testing // await sendNotificationAck(notificationKey, fromAtSign); - if (decryptedMessage != null && decryptedMessage != '') { + if (decryptedMessage != '') { await Provider.of(NavService.navKey.currentContext!, listen: false) .checkForUpdatedOrNewNotification(fromAtSign, decryptedMessage); @@ -235,20 +232,22 @@ class BackendService { transferId = transferId.split('@')[0]; transferId = transferId.replaceAll('.mospherepro', ''); transferId = transferId.replaceAll('file_transfer_', ''); - AtKey atKey = AtKey() - ..key = 'receive_ack_$transferId' - ..sharedWith = fromAtsign - ..metadata = Metadata() - ..metadata!.ttr = -1 - ..metadata!.ttl = 518400000; - - var notificationResult = - await AtClientManager.getInstance().notificationService.notify( - NotificationParams.forUpdate( - atKey, - value: 'receive_ack_$key', - ), - ); + // atKey isn't used + // AtKey atKey = AtKey() + // ..key = 'receive_ack_$transferId' + // ..sharedWith = fromAtsign + // ..metadata = Metadata() + // ..metadata!.ttr = -1 + // ..metadata!.ttl = 518400000; + + // noificationResult isn't used, apparently + // var notificationResult = + // await AtClientManager.getInstance().notificationService.notify( + // NotificationParams.forUpdate( + // atKey, + // value: 'receive_ack_$key', + // ), + // ); } catch (e) { print('error in ack: $e'); } @@ -538,7 +537,7 @@ class BackendService { MaterialPageRoute(builder: (context) => HistoryScreen(tabIndex: 1)), ); } else if (Platform.isMacOS) { - DesktopSetupRoutes.nested_push(DesktopRoutes.DESKTOP_HISTORY); + await DesktopSetupRoutes.nested_push(DesktopRoutes.DESKTOP_HISTORY); } } diff --git a/lib/services/common_utility_functions.dart b/lib/services/common_utility_functions.dart index 0cc3a1da..932e7a31 100644 --- a/lib/services/common_utility_functions.dart +++ b/lib/services/common_utility_functions.dart @@ -12,7 +12,6 @@ import 'package:atsign_atmosphere_pro/utils/colors.dart'; import 'package:atsign_atmosphere_pro/utils/file_types.dart'; import 'package:atsign_atmosphere_pro/utils/images.dart'; import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; import 'package:flutter/material.dart'; import 'package:video_thumbnail/video_thumbnail.dart'; @@ -29,8 +28,7 @@ class CommonUtilityFunctions { Uint8List? image; AtContact contact = checkForCachedContactDetail(atsign); - if (contact != null && - contact.tags != null && + if (contact.tags != null && contact.tags!['image'] != null) { try { return getContactImage(contact); @@ -57,8 +55,7 @@ class CommonUtilityFunctions { String? _name; AtContact contact = checkForCachedContactDetail(atsign); - if (contact != null && - contact.tags != null && + if (contact.tags != null && contact.tags!['name'] != null) { _name = contact.tags!['name'].toString(); } diff --git a/lib/services/file_transfer_service.dart b/lib/services/file_transfer_service.dart index b417228d..88b52db2 100644 --- a/lib/services/file_transfer_service.dart +++ b/lib/services/file_transfer_service.dart @@ -5,7 +5,6 @@ import 'dart:isolate'; // import 'package:at_client/src/stream/file_transfer_object.dart'; import 'package:at_client_mobile/at_client_mobile.dart'; -import 'package:at_commons/at_commons.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer_object.dart'; import 'package:atsign_atmosphere_pro/services/backend_service.dart'; @@ -15,7 +14,6 @@ import 'package:atsign_atmosphere_pro/view_models/file_progress_provider.dart'; import 'package:provider/provider.dart'; import 'package:uuid/uuid.dart'; import 'package:http/http.dart' as http; -import 'package:at_client/src/service/notification_service.dart'; import 'package:at_client/src/service/encryption_service.dart'; class FileTransferService { diff --git a/lib/services/overlay_service.dart b/lib/services/overlay_service.dart index 3f7a078b..3817f707 100644 --- a/lib/services/overlay_service.dart +++ b/lib/services/overlay_service.dart @@ -17,16 +17,16 @@ class OverlayService { static OverlayService get instance => _instance; OverlayEntry? snackBarOverlayEntry; - showOverlay(FLUSHBAR_STATUS flushbarStatus) async { + showOverlay(FlushbarStatus flushbarStatus) async { hideOverlay(); snackBarOverlayEntry = _buildSnackBarOverlayEntry(flushbarStatus); NavService.navKey.currentState?.overlay?.insert(snackBarOverlayEntry!); - if (flushbarStatus == FLUSHBAR_STATUS.DONE) { + if (flushbarStatus == FlushbarStatus.DONE) { await Future.delayed(Duration(seconds: 3)); hideOverlay(); - } else if (flushbarStatus == FLUSHBAR_STATUS.FAILED) { + } else if (flushbarStatus == FlushbarStatus.FAILED) { await Future.delayed(Duration(seconds: 5)); hideOverlay(); } @@ -37,7 +37,7 @@ class OverlayService { snackBarOverlayEntry = null; } - OverlayEntry _buildSnackBarOverlayEntry(FLUSHBAR_STATUS flushbarStatus) { + OverlayEntry _buildSnackBarOverlayEntry(FlushbarStatus flushbarStatus) { Color bgColor = _getColor(flushbarStatus); return OverlayEntry(builder: (context) { @@ -58,7 +58,7 @@ class OverlayService { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - flushbarStatus == FLUSHBAR_STATUS.SENDING + flushbarStatus == FlushbarStatus.SENDING ? provider.sentFileTransferProgress != null ? getProgressBar(provider.sentFileTransferProgress!) : LinearProgressIndicator() @@ -79,10 +79,10 @@ class OverlayService { maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle( - color: flushbarStatus == - FLUSHBAR_STATUS.SENDING - ? Colors.black - : Colors.white, + color: + flushbarStatus == FlushbarStatus.SENDING + ? Colors.black + : Colors.white, fontSize: 16.toFont, fontWeight: FontWeight.normal, ), @@ -97,7 +97,7 @@ class OverlayService { ], ), ), - flushbarStatus == FLUSHBAR_STATUS.FAILED + flushbarStatus == FlushbarStatus.FAILED ? TextButton( onPressed: () { openFileReceiptBottomSheet(context); @@ -153,10 +153,10 @@ class OverlayService { }); } - String _getText(FLUSHBAR_STATUS flushbarStatus, + String _getText(FlushbarStatus flushbarStatus, {FileTransferProgress? fileTransferProgress}) { switch (flushbarStatus) { - case FLUSHBAR_STATUS.SENDING: + case FlushbarStatus.SENDING: String sendingMessage = transferMessages[0]; if (fileTransferProgress != null) { if (fileTransferProgress.fileState == FileState.encrypt) { @@ -168,9 +168,9 @@ class OverlayService { } } return sendingMessage; - case FLUSHBAR_STATUS.DONE: + case FlushbarStatus.DONE: return transferMessages[1]; - case FLUSHBAR_STATUS.FAILED: + case FlushbarStatus.FAILED: return transferMessages[2]; default: return ''; @@ -213,13 +213,13 @@ class OverlayService { return LinearProgressIndicator(); } - Color _getColor(FLUSHBAR_STATUS flushbarStatus) { + Color _getColor(FlushbarStatus flushbarStatus) { switch (flushbarStatus) { - case FLUSHBAR_STATUS.SENDING: + case FlushbarStatus.SENDING: return Colors.amber; - case FLUSHBAR_STATUS.DONE: + case FlushbarStatus.DONE: return Color(0xFF5FAA45); - case FLUSHBAR_STATUS.FAILED: + case FlushbarStatus.FAILED: return ColorConstants.redAlert; default: return Colors.amber; diff --git a/lib/services/version_service.dart b/lib/services/version_service.dart index d1f1e7d4..f9d85487 100644 --- a/lib/services/version_service.dart +++ b/lib/services/version_service.dart @@ -184,11 +184,11 @@ class VersionService { url = MixedConstants.LINUX_STORE_LINK; } - if (await canLaunch(url)) { - await launch( - url, - forceSafariVC: false, - forceWebView: false, + if (await canLaunchUrl(Uri.parse(url))) { + await launchUrl( + Uri.parse(url), + // forceSafariVC: false, + // forceWebView: false, ); } } diff --git a/lib/utils/text_styles.dart b/lib/utils/text_styles.dart index 4e2bd4a7..8ea1e06b 100644 --- a/lib/utils/text_styles.dart +++ b/lib/utils/text_styles.dart @@ -1,4 +1,3 @@ -import 'dart:ui'; import 'package:atsign_atmosphere_pro/utils/colors.dart'; import 'package:flutter/material.dart'; diff --git a/lib/view_models/base_model.dart b/lib/view_models/base_model.dart index 709255fb..5622f2a8 100644 --- a/lib/view_models/base_model.dart +++ b/lib/view_models/base_model.dart @@ -9,13 +9,14 @@ class BaseModel with ChangeNotifier { } setError(String function, String _error, [Status? _status]) { - if (_error != null) { - error[function] = _error; - status[function] = Status.Error; - } else { - this.error[function] = null; - this.status[function] = _status ?? Status.Idle; - } + // unnecessary check: it'll always be true + // if (_error != null) { + error[function] = _error; + status[function] = Status.Error; + // } else { + // this.error[function] = null; + // this.status[function] = _status ?? Status.Idle; + // } notifyListeners(); } diff --git a/lib/view_models/file_transfer_provider.dart b/lib/view_models/file_transfer_provider.dart index 22eb375f..f18b5565 100644 --- a/lib/view_models/file_transfer_provider.dart +++ b/lib/view_models/file_transfer_provider.dart @@ -39,7 +39,7 @@ class FileTransferProvider extends BaseModel { List? _sharedFiles; FilePickerResult? result; PlatformFile? file; - FLUSHBAR_STATUS? flushbarStatus; + FlushbarStatus? flushbarStatus; List selectedFiles = []; List transferStatus = []; Map>> transferStatusMap = {}; @@ -50,9 +50,9 @@ class FileTransferProvider extends BaseModel { List temporaryContactList = []; bool hasSelectedFilesChanged = false, scrollToBottom = false; - final _flushBarStream = StreamController.broadcast(); - Stream get flushBarStatusStream => _flushBarStream.stream; - StreamSink get flushBarStatusSink => _flushBarStream.sink; + final _flushBarStream = StreamController.broadcast(); + Stream get flushBarStatusStream => _flushBarStream.stream; + StreamSink get flushBarStatusSink => _flushBarStream.sink; FileHistory? _selectedFileHistory; @@ -212,7 +212,7 @@ class FileTransferProvider extends BaseModel { Future sendFileWithFileBin( List selectedFiles, List contactList, {String? groupName, String? notes}) async { - flushBarStatusSink.add(FLUSHBAR_STATUS.SENDING); + flushBarStatusSink.add(FlushbarStatus.SENDING); setStatus(SEND_FILES, Status.Loading); var fileUploadProvider = Provider.of( NavService.navKey.currentContext!, @@ -261,20 +261,20 @@ class FileTransferProvider extends BaseModel { !atsignStatus.value.sharedStatus!) { fileUploadProvider.removeSentFileProgress(); setStatus(SEND_FILES, Status.Error); - flushBarStatusSink.add(FLUSHBAR_STATUS.FAILED); + flushBarStatusSink.add(FlushbarStatus.FAILED); return false; } } fileUploadProvider.removeSentFileProgress(); - flushBarStatusSink.add(FLUSHBAR_STATUS.DONE); + flushBarStatusSink.add(FlushbarStatus.DONE); setStatus(SEND_FILES, Status.Done); return true; } catch (e) { fileUploadProvider.removeSentFileProgress(); setStatus(SEND_FILES, Status.Error); - flushBarStatusSink.add(FLUSHBAR_STATUS.FAILED); + flushBarStatusSink.add(FlushbarStatus.FAILED); } } @@ -292,7 +292,7 @@ class FileTransferProvider extends BaseModel { } try { - flushBarStatusSink.add(FLUSHBAR_STATUS.SENDING); + flushBarStatusSink.add(FlushbarStatus.SENDING); // reuploading files for (var fileData in _fileHistory.fileDetails!.files!) { @@ -314,14 +314,14 @@ class FileTransferProvider extends BaseModel { for (var element in _fileHistory.sharedWith!) { if (element.isNotificationSend != null && !element.isNotificationSend!) { - flushBarStatusSink.add(FLUSHBAR_STATUS.FAILED); + flushBarStatusSink.add(FlushbarStatus.FAILED); return false; } } - flushBarStatusSink.add(FLUSHBAR_STATUS.DONE); + flushBarStatusSink.add(FlushbarStatus.DONE); return true; } catch (e) { - flushBarStatusSink.add(FLUSHBAR_STATUS.FAILED); + flushBarStatusSink.add(FlushbarStatus.FAILED); return false; } } @@ -455,4 +455,4 @@ class FileTransferProvider extends BaseModel { } } -enum FLUSHBAR_STATUS { IDLE, SENDING, FAILED, DONE } +enum FlushbarStatus { IDLE, SENDING, FAILED, DONE } diff --git a/lib/view_models/history_provider.dart b/lib/view_models/history_provider.dart index 3301ce45..75eb4aeb 100644 --- a/lib/view_models/history_provider.dart +++ b/lib/view_models/history_provider.dart @@ -1,7 +1,6 @@ import 'dart:convert'; import 'dart:io'; import 'package:at_client_mobile/at_client_mobile.dart'; -import 'package:at_commons/at_commons.dart'; import 'package:at_contacts_flutter/services/contact_service.dart'; import 'package:atsign_atmosphere_pro/data_models/file_modal.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; @@ -34,10 +33,6 @@ import 'package:atsign_atmosphere_pro/view_models/file_progress_provider.dart'; import 'package:flutter/cupertino.dart'; // import 'package:at_client/src/stream/file_transfer_object.dart'; import 'package:flutter/services.dart'; -import 'package:http/http.dart' as http; -import 'package:at_client/src/service/notification_service.dart'; -import 'package:provider/provider.dart'; -import 'package:at_client/src/service/notification_service.dart'; import 'package:provider/provider.dart'; import 'file_download_checker.dart'; @@ -235,7 +230,7 @@ class HistoryProvider extends BaseModel { print('error in getSentHistory : $e'); return AtValue(); }); - if (keyValue != null && keyValue.value != null) { + if (keyValue.value != null) { try { Map historyFile = json.decode((keyValue.value) as String) as Map; sendFileHistory['history'] = historyFile['history']; @@ -289,7 +284,7 @@ class HistoryProvider extends BaseModel { }, ); - if (atvalue != null && atvalue.value != null) { + if (atvalue.value != null) { try { FileHistory fileHistory = FileHistory.fromJson( jsonDecode(atvalue.value), @@ -397,7 +392,7 @@ class HistoryProvider extends BaseModel { print('error in get in getFileDownloadedAcknowledgement : $e'); return AtValue(); }); - if (atValue != null && atValue.value != null) { + if (atValue.value != null) { var downloadAcknowledgement = DownloadAcknowledgement.fromJson(jsonDecode(atValue.value)); @@ -605,7 +600,7 @@ class HistoryProvider extends BaseModel { return AtValue(); }); - if (atvalue != null && atvalue.value != null) { + if (atvalue.value != null) { try { FileTransferObject fileTransferObject = FileTransferObject.fromJson(jsonDecode(atvalue.value))!; @@ -613,9 +608,7 @@ class HistoryProvider extends BaseModel { convertFiletransferObjectToFileTransfer(fileTransferObject); filesModel.sender = atKey.sharedBy!; - if (filesModel.key != null) { - tempReceivedHistoryLogs.insert(0, filesModel); - } + tempReceivedHistoryLogs.insert(0, filesModel); } catch (e) { print('error in getAllFileTransferData file model conversion: $e'); } @@ -1045,24 +1038,25 @@ class HistoryProvider extends BaseModel { receivedHistoryLogs[index].isWidgetOpen = isWidgetOpen; } notifyListeners(); - - var files = - await _downloadSingleFileFromWeb(transferId, sharedBy, fileName); + // files isn't used + // var files = + // await _downloadSingleFileFromWeb(transferId, sharedBy, fileName); receivedHistoryLogs[index].files![_fileIndex].isDownloading = false; Provider.of(NavService.navKey.currentContext!, listen: false) .checkForUndownloadedFiles(); - if (files is List) { - await sortFiles(receivedHistoryLogs); - populateTabs(); - setStatus(DOWNLOAD_FILE, Status.Done); - return true; - } else { - setStatus(DOWNLOAD_FILE, Status.Done); - return false; - } + // unnecessary check: it'll always be true + // if (files is List) { + await sortFiles(receivedHistoryLogs); + populateTabs(); + setStatus(DOWNLOAD_FILE, Status.Done); + return true; + // } else { + // setStatus(DOWNLOAD_FILE, Status.Done); + // return false; + // } } catch (e) { print('error in downloading file: $e'); Provider.of(NavService.navKey.currentContext!, @@ -1074,6 +1068,8 @@ class HistoryProvider extends BaseModel { } } + /* This function isn't even referenced/used + Future> _downloadSingleFileFromWeb( String? transferId, String? sharedByAtSign, String fileName, {String? downloadPath}) async { @@ -1091,9 +1087,10 @@ class HistoryProvider extends BaseModel { return AtValue(); }); - if (result == null) { - return []; - } + // result can't be null + // if (result == null) { + // return []; + // } FileTransferObject? fileTransferObject; try { var _jsonData = jsonDecode(result.value); @@ -1155,6 +1152,7 @@ class HistoryProvider extends BaseModel { return []; } } + */ Future sendFileDownloadAcknowledgement( FileTransfer fileTransfer) async { diff --git a/lib/view_models/trusted_sender_view_model.dart b/lib/view_models/trusted_sender_view_model.dart index 2565327c..15627ecb 100644 --- a/lib/view_models/trusted_sender_view_model.dart +++ b/lib/view_models/trusted_sender_view_model.dart @@ -1,7 +1,6 @@ import 'dart:convert'; import 'package:at_client_mobile/at_client_mobile.dart'; -import 'package:at_commons/at_commons.dart'; import 'package:at_contact/at_contact.dart'; import 'package:atsign_atmosphere_pro/services/backend_service.dart'; import 'package:atsign_atmosphere_pro/view_models/base_model.dart'; @@ -95,7 +94,7 @@ class TrustedContactProvider extends BaseModel { }); var jsonValue; - if (keyValue != null && keyValue.value != null) { + if (keyValue.value != null) { jsonValue = jsonDecode(keyValue.value); jsonValue['trustedContacts'].forEach((contact) { final c = AtContact.fromJson(contact);