diff --git a/analysis_options.yaml b/analysis_options.yaml index 0537fc253..0c9cce807 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -58,6 +58,7 @@ analyzer: unnecessary_const: error cancel_subscriptions: error + invalid_dependency: info use_build_context_synchronously: ignore # experimental lint, requires many changes prefer_interpolation_to_compose_strings: ignore # later too many warnings prefer_double_quotes: ignore # too many warnings diff --git a/lib/core/network.dart b/lib/core/network.dart index eb83f8175..0d396e5d7 100644 --- a/lib/core/network.dart +++ b/lib/core/network.dart @@ -66,8 +66,10 @@ class EnteRequestInterceptor extends Interceptor { @override void onRequest(RequestOptions options, RequestInterceptorHandler handler) { if (kDebugMode) { - assert(options.baseUrl == Network.apiEndpoint, - "interceptor should only be used for API endpoint"); + assert( + options.baseUrl == Network.apiEndpoint, + "interceptor should only be used for API endpoint", + ); } // ignore: prefer_const_constructors options.headers.putIfAbsent("x-request-id", () => Uuid().v4().toString()); diff --git a/lib/db/files_db.dart b/lib/db/files_db.dart index 3e2576673..be292fcf1 100644 --- a/lib/db/files_db.dart +++ b/lib/db/files_db.dart @@ -1261,7 +1261,8 @@ class FilesDB { } Future>> getAllFilesGroupByCollectionID( - List ids) async { + List ids, + ) async { final result = >{}; if (ids.isEmpty) { return result; diff --git a/lib/models/file.dart b/lib/models/file.dart index b48082d20..a620ed090 100644 --- a/lib/models/file.dart +++ b/lib/models/file.dart @@ -161,9 +161,9 @@ class File extends EnteFile { duration = asset.duration; } } - if (fileType == FileType.image) { + if (fileType == FileType.image && mediaUploadData.sourceFile != null) { final exifTime = - await getCreationTimeFromEXIF(mediaUploadData.sourceFile); + await getCreationTimeFromEXIF(mediaUploadData.sourceFile!); if (exifTime != null) { creationTime = exifTime.microsecondsSinceEpoch; } diff --git a/lib/services/local/local_sync_util.dart b/lib/services/local/local_sync_util.dart index 76c5997a4..b3f8e6ac6 100644 --- a/lib/services/local/local_sync_util.dart +++ b/lib/services/local/local_sync_util.dart @@ -264,8 +264,10 @@ Future> _getAllAssetLists(AssetPathEntity pathEntity) async { size: assetFetchPageSize, ); Bus.instance.fire( - LocalImportProgressEvent(pathEntity.name, - currentPage * assetFetchPageSize + currentPageResult.length), + LocalImportProgressEvent( + pathEntity.name, + currentPage * assetFetchPageSize + currentPageResult.length, + ), ); result.addAll(currentPageResult); currentPage = currentPage + 1; diff --git a/lib/services/remote_sync_service.dart b/lib/services/remote_sync_service.dart index 5b1f3195c..8c0314800 100644 --- a/lib/services/remote_sync_service.dart +++ b/lib/services/remote_sync_service.dart @@ -360,16 +360,20 @@ class RemoteSyncService { if (pendingUploads.isEmpty) { continue; } else { - _logger.info("RemovingFiles $collectionIDs: pendingUploads " - "${pendingUploads.length}"); + _logger.info( + "RemovingFiles $collectionIDs: pendingUploads " + "${pendingUploads.length}", + ); } final Set localIDsInOtherFileEntries = await _db.getLocalIDsPresentInEntries( pendingUploads, collectionID, ); - _logger.info("RemovingFiles $collectionIDs: filesInOtherCollection " - "${localIDsInOtherFileEntries.length}"); + _logger.info( + "RemovingFiles $collectionIDs: filesInOtherCollection " + "${localIDsInOtherFileEntries.length}", + ); final List entriesToUpdate = []; final List entriesToDelete = []; for (File pendingUpload in pendingUploads) { diff --git a/lib/ui/account/recovery_key_page.dart b/lib/ui/account/recovery_key_page.dart index e5b561a24..7990d078f 100644 --- a/lib/ui/account/recovery_key_page.dart +++ b/lib/ui/account/recovery_key_page.dart @@ -63,142 +63,148 @@ class _RecoveryKeyPageState extends State { : 120; return Scaffold( - appBar: widget.showProgressBar - ? AppBar( - elevation: 0, - title: Hero( - tag: "recovery_key", - child: StepProgressIndicator( - totalSteps: 4, - currentStep: 3, - selectedColor: - Theme.of(context).colorScheme.greenAlternative, - roundedEdges: const Radius.circular(10), - unselectedColor: Theme.of(context) - .colorScheme - .stepProgressUnselectedColor, - ), + appBar: widget.showProgressBar + ? AppBar( + elevation: 0, + title: Hero( + tag: "recovery_key", + child: StepProgressIndicator( + totalSteps: 4, + currentStep: 3, + selectedColor: Theme.of(context).colorScheme.greenAlternative, + roundedEdges: const Radius.circular(10), + unselectedColor: + Theme.of(context).colorScheme.stepProgressUnselectedColor, ), - ) - : widget.showAppBar - ? AppBar( - elevation: 0, - title: Text(widget.title ?? "Recovery key"), - ) - : null, - body: Padding( - padding: EdgeInsets.fromLTRB(20, topPadding, 20, 20), - child: LayoutBuilder( - builder: (context, constraints) { - return SingleChildScrollView( - child: ConstrainedBox( - constraints: BoxConstraints( - minWidth: constraints.maxWidth, - minHeight: constraints.maxHeight), - child: IntrinsicHeight( - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - widget.showAppBar - ? const SizedBox.shrink() - : Text( - widget.title ?? "Recovery key", - style: Theme.of(context).textTheme.headline4, - ), - Padding( - padding: - EdgeInsets.all(widget.showAppBar ? 0 : 12)), - Text( - widget.text ?? - "If you forget your password, the only way you can recover your data is with this key.", - style: Theme.of(context).textTheme.subtitle1, - ), - const Padding(padding: EdgeInsets.only(top: 24)), - DottedBorder( - color: const Color.fromRGBO(17, 127, 56, 1), - //color of dotted/dash line - strokeWidth: 1, - //thickness of dash/dots - dashPattern: const [6, 6], - radius: const Radius.circular(8), - //dash patterns, 10 is dash width, 6 is space width - child: SizedBox( - //inner container - // height: 120, //height of inner container - width: double - .infinity, //width to 100% match to parent container. - // ignore: prefer_const_literals_to_create_immutables - child: Column( - children: [ - GestureDetector( - onTap: () async { - await Clipboard.setData( - ClipboardData(text: recoveryKey), - ); - showToast(context, - "Recovery key copied to clipboard"); - setState(() { - _hasTriedToSave = true; - }); - }, - child: Container( - decoration: BoxDecoration( - border: Border.all( - color: const Color.fromRGBO( - 49, 155, 86, .2), + ), + ) + : widget.showAppBar + ? AppBar( + elevation: 0, + title: Text(widget.title ?? "Recovery key"), + ) + : null, + body: Padding( + padding: EdgeInsets.fromLTRB(20, topPadding, 20, 20), + child: LayoutBuilder( + builder: (context, constraints) { + return SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints( + minWidth: constraints.maxWidth, + minHeight: constraints.maxHeight, + ), + child: IntrinsicHeight( + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + widget.showAppBar + ? const SizedBox.shrink() + : Text( + widget.title ?? "Recovery key", + style: Theme.of(context).textTheme.headline4, + ), + Padding( + padding: EdgeInsets.all(widget.showAppBar ? 0 : 12), + ), + Text( + widget.text ?? + "If you forget your password, the only way you can recover your data is with this key.", + style: Theme.of(context).textTheme.subtitle1, + ), + const Padding(padding: EdgeInsets.only(top: 24)), + DottedBorder( + color: const Color.fromRGBO(17, 127, 56, 1), + //color of dotted/dash line + strokeWidth: 1, + //thickness of dash/dots + dashPattern: const [6, 6], + radius: const Radius.circular(8), + //dash patterns, 10 is dash width, 6 is space width + child: SizedBox( + //inner container + // height: 120, //height of inner container + width: double + .infinity, //width to 100% match to parent container. + // ignore: prefer_const_literals_to_create_immutables + child: Column( + children: [ + GestureDetector( + onTap: () async { + await Clipboard.setData( + ClipboardData(text: recoveryKey), + ); + showToast( + context, + "Recovery key copied to clipboard", + ); + setState(() { + _hasTriedToSave = true; + }); + }, + child: Container( + decoration: BoxDecoration( + border: Border.all( + color: const Color.fromRGBO( + 49, + 155, + 86, + .2, ), - borderRadius: const BorderRadius.all( - Radius.circular(2), - ), - color: Theme.of(context) - .colorScheme - .recoveryKeyBoxColor, ), - padding: const EdgeInsets.all(20), - width: double.infinity, - child: Text( - recoveryKey, - style: - Theme.of(context).textTheme.bodyText1, + borderRadius: const BorderRadius.all( + Radius.circular(2), ), + color: Theme.of(context) + .colorScheme + .recoveryKeyBoxColor, + ), + padding: const EdgeInsets.all(20), + width: double.infinity, + child: Text( + recoveryKey, + style: + Theme.of(context).textTheme.bodyText1, ), ), - ], - ), + ), + ], ), ), - SizedBox( - height: 80, + ), + SizedBox( + height: 80, + width: double.infinity, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 20), + child: Text( + widget.subText ?? + "We don’t store this key, please save this in a safe place.", + style: Theme.of(context).textTheme.bodyText1, + ), + ), + ), + Expanded( + child: Container( + alignment: Alignment.bottomCenter, width: double.infinity, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 20), - child: Text( - widget.subText ?? - "We don’t store this key, please save this in a safe place.", - style: Theme.of(context).textTheme.bodyText1, - ), + padding: const EdgeInsets.fromLTRB(10, 10, 10, 42), + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: _saveOptions(context, recoveryKey), ), ), - Expanded( - child: Container( - alignment: Alignment.bottomCenter, - width: double.infinity, - padding: const EdgeInsets.fromLTRB(10, 10, 10, 42), - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: _saveOptions(context, recoveryKey), - ), - ), - ) - ], - ), // columnEnds - ), + ) + ], + ), // columnEnds ), - ); - }, - ), - )); + ), + ); + }, + ), + ), + ); } List _saveOptions(BuildContext context, String recoveryKey) { diff --git a/lib/ui/home/home_bottom_nav_bar.dart b/lib/ui/home/home_bottom_nav_bar.dart index 554160c5d..2ec79c802 100644 --- a/lib/ui/home/home_bottom_nav_bar.dart +++ b/lib/ui/home/home_bottom_nav_bar.dart @@ -41,8 +41,10 @@ class _HomeBottomNavigationBarState extends State { _tabChangedEventSubscription = Bus.instance.on().listen((event) { if (event.source != TabChangedEventSource.tabBar) { - debugPrint('${(TabChangedEvent).toString()} index changed from ' - '$currentTabIndex to ${event.selectedIndex} via ${event.source}'); + debugPrint( + '${(TabChangedEvent).toString()} index changed from ' + '$currentTabIndex to ${event.selectedIndex} via ${event.source}', + ); if (mounted) { setState(() { currentTabIndex = event.selectedIndex; diff --git a/lib/ui/home_widget.dart b/lib/ui/home_widget.dart index 9ae605e4f..eb85a9ae2 100644 --- a/lib/ui/home_widget.dart +++ b/lib/ui/home_widget.dart @@ -89,7 +89,8 @@ class _HomeWidgetState extends State { Bus.instance.on().listen((event) { if (event.source != TabChangedEventSource.pageView) { debugPrint( - "TabChange going from $_selectedTabIndex to ${event.selectedIndex} souce: ${event.source}"); + "TabChange going from $_selectedTabIndex to ${event.selectedIndex} souce: ${event.source}", + ); _selectedTabIndex = event.selectedIndex; // _pageController.jumpToPage(_selectedTabIndex); _pageController.animateToPage( diff --git a/lib/ui/huge_listview/huge_listview.dart b/lib/ui/huge_listview/huge_listview.dart index 3bd8abf3a..9bb16cf18 100644 --- a/lib/ui/huge_listview/huge_listview.dart +++ b/lib/ui/huge_listview/huge_listview.dart @@ -1,6 +1,6 @@ // @dart=2.9 -import 'dart:math' show max, min; +import 'dart:math' show max; import 'package:flutter/material.dart'; import 'package:photos/ui/huge_listview/draggable_scrollbar.dart'; diff --git a/lib/ui/payment/stripe_subscription_page.dart b/lib/ui/payment/stripe_subscription_page.dart index a56b02498..f4b85d413 100644 --- a/lib/ui/payment/stripe_subscription_page.dart +++ b/lib/ui/payment/stripe_subscription_page.dart @@ -3,7 +3,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:logging/logging.dart'; import 'package:photos/ente_theme_data.dart'; import 'package:photos/models/billing_plan.dart'; import 'package:photos/models/subscription.dart'; @@ -38,7 +37,6 @@ class StripeSubscriptionPage extends StatefulWidget { } class _StripeSubscriptionPageState extends State { - final _logger = Logger("StripeSubscriptionPage"); final _billingService = BillingService.instance; final _userService = UserService.instance; Subscription _currentSubscription; diff --git a/lib/ui/settings/app_version_widget.dart b/lib/ui/settings/app_version_widget.dart index ac9f36b0f..a991dafad 100644 --- a/lib/ui/settings/app_version_widget.dart +++ b/lib/ui/settings/app_version_widget.dart @@ -15,7 +15,6 @@ class AppVersionWidget extends StatefulWidget { class _AppVersionWidgetState extends State { static const kTapThresholdForInspector = 5; static const kConsecutiveTapTimeWindowInMilliseconds = 2000; - static const kDummyDelayDurationInMilliseconds = 1500; int _lastTap; int _consecutiveTaps = 0; diff --git a/lib/ui/viewer/file/fading_app_bar.dart b/lib/ui/viewer/file/fading_app_bar.dart index 274153953..39bd20800 100644 --- a/lib/ui/viewer/file/fading_app_bar.dart +++ b/lib/ui/viewer/file/fading_app_bar.dart @@ -471,7 +471,10 @@ class FadingAppBarState extends State { } Future _saveLivePhotoOnDroid( - io.File image, io.File video, File enteFile) async { + io.File image, + io.File video, + File enteFile, + ) async { debugPrint("Downloading LivePhoto on Droid"); AssetEntity savedAsset = await PhotoManager.editor .saveImageWithPath(image.path, title: enteFile.title); diff --git a/lib/utils/exif_util.dart b/lib/utils/exif_util.dart index dd1eff63e..3a284f067 100644 --- a/lib/utils/exif_util.dart +++ b/lib/utils/exif_util.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'dart:io' as io; import 'package:exif/exif.dart'; @@ -29,18 +27,16 @@ Future> getExif(File file) async { } } -Future getCreationTimeFromEXIF(io.File file) async { +Future getCreationTimeFromEXIF(io.File file) async { try { final exif = await readExifFromFile(file); - if (exif != null) { - final exifTime = exif.containsKey(kDateTimeOriginal) - ? exif[kDateTimeOriginal].printable - : exif.containsKey(kImageDateTime) - ? exif[kImageDateTime].printable - : null; - if (exifTime != null && exifTime != kEmptyExifDateTime) { - return DateFormat(kExifDateTimePattern).parse(exifTime); - } + final exifTime = exif.containsKey(kDateTimeOriginal) + ? exif[kDateTimeOriginal]!.printable + : exif.containsKey(kImageDateTime) + ? exif[kImageDateTime]!.printable + : null; + if (exifTime != null && exifTime != kEmptyExifDateTime) { + return DateFormat(kExifDateTimePattern).parse(exifTime); } } catch (e) { _logger.severe("failed to getCreationTimeFromEXIF", e); diff --git a/lib/utils/file_uploader.dart b/lib/utils/file_uploader.dart index 9869f99f3..d71f17dfc 100644 --- a/lib/utils/file_uploader.dart +++ b/lib/utils/file_uploader.dart @@ -188,7 +188,8 @@ class FileUploader { _queue.remove(id).completer.completeError(reason); } _logger.info( - 'number of enteries removed from queue ${uploadsToBeRemoved.length}'); + 'number of enteries removed from queue ${uploadsToBeRemoved.length}', + ); _totalCountInUploadSession -= uploadsToBeRemoved.length; }