Fix lint issues

This commit is contained in:
Neeraj Gupta 2022-11-06 13:52:54 +05:30
parent 918d00123e
commit 19cc54f422
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
15 changed files with 172 additions and 156 deletions

View file

@ -58,6 +58,7 @@ analyzer:
unnecessary_const: error unnecessary_const: error
cancel_subscriptions: error cancel_subscriptions: error
invalid_dependency: info
use_build_context_synchronously: ignore # experimental lint, requires many changes use_build_context_synchronously: ignore # experimental lint, requires many changes
prefer_interpolation_to_compose_strings: ignore # later too many warnings prefer_interpolation_to_compose_strings: ignore # later too many warnings
prefer_double_quotes: ignore # too many warnings prefer_double_quotes: ignore # too many warnings

View file

@ -66,8 +66,10 @@ class EnteRequestInterceptor extends Interceptor {
@override @override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) { void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
if (kDebugMode) { if (kDebugMode) {
assert(options.baseUrl == Network.apiEndpoint, assert(
"interceptor should only be used for API endpoint"); options.baseUrl == Network.apiEndpoint,
"interceptor should only be used for API endpoint",
);
} }
// ignore: prefer_const_constructors // ignore: prefer_const_constructors
options.headers.putIfAbsent("x-request-id", () => Uuid().v4().toString()); options.headers.putIfAbsent("x-request-id", () => Uuid().v4().toString());

View file

@ -1261,7 +1261,8 @@ class FilesDB {
} }
Future<Map<int, List<File>>> getAllFilesGroupByCollectionID( Future<Map<int, List<File>>> getAllFilesGroupByCollectionID(
List<int> ids) async { List<int> ids,
) async {
final result = <int, List<File>>{}; final result = <int, List<File>>{};
if (ids.isEmpty) { if (ids.isEmpty) {
return result; return result;

View file

@ -161,9 +161,9 @@ class File extends EnteFile {
duration = asset.duration; duration = asset.duration;
} }
} }
if (fileType == FileType.image) { if (fileType == FileType.image && mediaUploadData.sourceFile != null) {
final exifTime = final exifTime =
await getCreationTimeFromEXIF(mediaUploadData.sourceFile); await getCreationTimeFromEXIF(mediaUploadData.sourceFile!);
if (exifTime != null) { if (exifTime != null) {
creationTime = exifTime.microsecondsSinceEpoch; creationTime = exifTime.microsecondsSinceEpoch;
} }

View file

@ -264,8 +264,10 @@ Future<List<AssetEntity>> _getAllAssetLists(AssetPathEntity pathEntity) async {
size: assetFetchPageSize, size: assetFetchPageSize,
); );
Bus.instance.fire( Bus.instance.fire(
LocalImportProgressEvent(pathEntity.name, LocalImportProgressEvent(
currentPage * assetFetchPageSize + currentPageResult.length), pathEntity.name,
currentPage * assetFetchPageSize + currentPageResult.length,
),
); );
result.addAll(currentPageResult); result.addAll(currentPageResult);
currentPage = currentPage + 1; currentPage = currentPage + 1;

View file

@ -360,16 +360,20 @@ class RemoteSyncService {
if (pendingUploads.isEmpty) { if (pendingUploads.isEmpty) {
continue; continue;
} else { } else {
_logger.info("RemovingFiles $collectionIDs: pendingUploads " _logger.info(
"${pendingUploads.length}"); "RemovingFiles $collectionIDs: pendingUploads "
"${pendingUploads.length}",
);
} }
final Set<String> localIDsInOtherFileEntries = final Set<String> localIDsInOtherFileEntries =
await _db.getLocalIDsPresentInEntries( await _db.getLocalIDsPresentInEntries(
pendingUploads, pendingUploads,
collectionID, collectionID,
); );
_logger.info("RemovingFiles $collectionIDs: filesInOtherCollection " _logger.info(
"${localIDsInOtherFileEntries.length}"); "RemovingFiles $collectionIDs: filesInOtherCollection "
"${localIDsInOtherFileEntries.length}",
);
final List<File> entriesToUpdate = []; final List<File> entriesToUpdate = [];
final List<int> entriesToDelete = []; final List<int> entriesToDelete = [];
for (File pendingUpload in pendingUploads) { for (File pendingUpload in pendingUploads) {

View file

@ -63,142 +63,148 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
: 120; : 120;
return Scaffold( return Scaffold(
appBar: widget.showProgressBar appBar: widget.showProgressBar
? AppBar( ? AppBar(
elevation: 0, elevation: 0,
title: Hero( title: Hero(
tag: "recovery_key", tag: "recovery_key",
child: StepProgressIndicator( child: StepProgressIndicator(
totalSteps: 4, totalSteps: 4,
currentStep: 3, currentStep: 3,
selectedColor: selectedColor: Theme.of(context).colorScheme.greenAlternative,
Theme.of(context).colorScheme.greenAlternative, roundedEdges: const Radius.circular(10),
roundedEdges: const Radius.circular(10), unselectedColor:
unselectedColor: Theme.of(context) Theme.of(context).colorScheme.stepProgressUnselectedColor,
.colorScheme
.stepProgressUnselectedColor,
),
), ),
) ),
: widget.showAppBar )
? AppBar( : widget.showAppBar
elevation: 0, ? AppBar(
title: Text(widget.title ?? "Recovery key"), elevation: 0,
) title: Text(widget.title ?? "Recovery key"),
: null, )
body: Padding( : null,
padding: EdgeInsets.fromLTRB(20, topPadding, 20, 20), body: Padding(
child: LayoutBuilder( padding: EdgeInsets.fromLTRB(20, topPadding, 20, 20),
builder: (context, constraints) { child: LayoutBuilder(
return SingleChildScrollView( builder: (context, constraints) {
child: ConstrainedBox( return SingleChildScrollView(
constraints: BoxConstraints( child: ConstrainedBox(
minWidth: constraints.maxWidth, constraints: BoxConstraints(
minHeight: constraints.maxHeight), minWidth: constraints.maxWidth,
child: IntrinsicHeight( minHeight: constraints.maxHeight,
child: Column( ),
mainAxisSize: MainAxisSize.max, child: IntrinsicHeight(
children: [ child: Column(
widget.showAppBar mainAxisSize: MainAxisSize.max,
? const SizedBox.shrink() children: [
: Text( widget.showAppBar
widget.title ?? "Recovery key", ? const SizedBox.shrink()
style: Theme.of(context).textTheme.headline4, : Text(
), widget.title ?? "Recovery key",
Padding( style: Theme.of(context).textTheme.headline4,
padding: ),
EdgeInsets.all(widget.showAppBar ? 0 : 12)), Padding(
Text( padding: EdgeInsets.all(widget.showAppBar ? 0 : 12),
widget.text ?? ),
"If you forget your password, the only way you can recover your data is with this key.", Text(
style: Theme.of(context).textTheme.subtitle1, widget.text ??
), "If you forget your password, the only way you can recover your data is with this key.",
const Padding(padding: EdgeInsets.only(top: 24)), style: Theme.of(context).textTheme.subtitle1,
DottedBorder( ),
color: const Color.fromRGBO(17, 127, 56, 1), const Padding(padding: EdgeInsets.only(top: 24)),
//color of dotted/dash line DottedBorder(
strokeWidth: 1, color: const Color.fromRGBO(17, 127, 56, 1),
//thickness of dash/dots //color of dotted/dash line
dashPattern: const [6, 6], strokeWidth: 1,
radius: const Radius.circular(8), //thickness of dash/dots
//dash patterns, 10 is dash width, 6 is space width dashPattern: const [6, 6],
child: SizedBox( radius: const Radius.circular(8),
//inner container //dash patterns, 10 is dash width, 6 is space width
// height: 120, //height of inner container child: SizedBox(
width: double //inner container
.infinity, //width to 100% match to parent container. // height: 120, //height of inner container
// ignore: prefer_const_literals_to_create_immutables width: double
child: Column( .infinity, //width to 100% match to parent container.
children: [ // ignore: prefer_const_literals_to_create_immutables
GestureDetector( child: Column(
onTap: () async { children: [
await Clipboard.setData( GestureDetector(
ClipboardData(text: recoveryKey), onTap: () async {
); await Clipboard.setData(
showToast(context, ClipboardData(text: recoveryKey),
"Recovery key copied to clipboard"); );
setState(() { showToast(
_hasTriedToSave = true; context,
}); "Recovery key copied to clipboard",
}, );
child: Container( setState(() {
decoration: BoxDecoration( _hasTriedToSave = true;
border: Border.all( });
color: const Color.fromRGBO( },
49, 155, 86, .2), 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), borderRadius: const BorderRadius.all(
width: double.infinity, Radius.circular(2),
child: Text(
recoveryKey,
style:
Theme.of(context).textTheme.bodyText1,
), ),
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 dont 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, width: double.infinity,
child: Padding( padding: const EdgeInsets.fromLTRB(10, 10, 10, 42),
padding: const EdgeInsets.symmetric(vertical: 20), child: Column(
child: Text( mainAxisAlignment: MainAxisAlignment.end,
widget.subText ?? crossAxisAlignment: CrossAxisAlignment.stretch,
"We dont store this key, please save this in a safe place.", children: _saveOptions(context, recoveryKey),
style: Theme.of(context).textTheme.bodyText1,
),
), ),
), ),
Expanded( )
child: Container( ],
alignment: Alignment.bottomCenter, ), // columnEnds
width: double.infinity,
padding: const EdgeInsets.fromLTRB(10, 10, 10, 42),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: _saveOptions(context, recoveryKey),
),
),
)
],
), // columnEnds
),
), ),
); ),
}, );
), },
)); ),
),
);
} }
List<Widget> _saveOptions(BuildContext context, String recoveryKey) { List<Widget> _saveOptions(BuildContext context, String recoveryKey) {

View file

@ -41,8 +41,10 @@ class _HomeBottomNavigationBarState extends State<HomeBottomNavigationBar> {
_tabChangedEventSubscription = _tabChangedEventSubscription =
Bus.instance.on<TabChangedEvent>().listen((event) { Bus.instance.on<TabChangedEvent>().listen((event) {
if (event.source != TabChangedEventSource.tabBar) { if (event.source != TabChangedEventSource.tabBar) {
debugPrint('${(TabChangedEvent).toString()} index changed from ' debugPrint(
'$currentTabIndex to ${event.selectedIndex} via ${event.source}'); '${(TabChangedEvent).toString()} index changed from '
'$currentTabIndex to ${event.selectedIndex} via ${event.source}',
);
if (mounted) { if (mounted) {
setState(() { setState(() {
currentTabIndex = event.selectedIndex; currentTabIndex = event.selectedIndex;

View file

@ -89,7 +89,8 @@ class _HomeWidgetState extends State<HomeWidget> {
Bus.instance.on<TabChangedEvent>().listen((event) { Bus.instance.on<TabChangedEvent>().listen((event) {
if (event.source != TabChangedEventSource.pageView) { if (event.source != TabChangedEventSource.pageView) {
debugPrint( debugPrint(
"TabChange going from $_selectedTabIndex to ${event.selectedIndex} souce: ${event.source}"); "TabChange going from $_selectedTabIndex to ${event.selectedIndex} souce: ${event.source}",
);
_selectedTabIndex = event.selectedIndex; _selectedTabIndex = event.selectedIndex;
// _pageController.jumpToPage(_selectedTabIndex); // _pageController.jumpToPage(_selectedTabIndex);
_pageController.animateToPage( _pageController.animateToPage(

View file

@ -1,6 +1,6 @@
// @dart=2.9 // @dart=2.9
import 'dart:math' show max, min; import 'dart:math' show max;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:photos/ui/huge_listview/draggable_scrollbar.dart'; import 'package:photos/ui/huge_listview/draggable_scrollbar.dart';

View file

@ -3,7 +3,6 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:photos/ente_theme_data.dart'; import 'package:photos/ente_theme_data.dart';
import 'package:photos/models/billing_plan.dart'; import 'package:photos/models/billing_plan.dart';
import 'package:photos/models/subscription.dart'; import 'package:photos/models/subscription.dart';
@ -38,7 +37,6 @@ class StripeSubscriptionPage extends StatefulWidget {
} }
class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> { class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
final _logger = Logger("StripeSubscriptionPage");
final _billingService = BillingService.instance; final _billingService = BillingService.instance;
final _userService = UserService.instance; final _userService = UserService.instance;
Subscription _currentSubscription; Subscription _currentSubscription;

View file

@ -15,7 +15,6 @@ class AppVersionWidget extends StatefulWidget {
class _AppVersionWidgetState extends State<AppVersionWidget> { class _AppVersionWidgetState extends State<AppVersionWidget> {
static const kTapThresholdForInspector = 5; static const kTapThresholdForInspector = 5;
static const kConsecutiveTapTimeWindowInMilliseconds = 2000; static const kConsecutiveTapTimeWindowInMilliseconds = 2000;
static const kDummyDelayDurationInMilliseconds = 1500;
int _lastTap; int _lastTap;
int _consecutiveTaps = 0; int _consecutiveTaps = 0;

View file

@ -471,7 +471,10 @@ class FadingAppBarState extends State<FadingAppBar> {
} }
Future<void> _saveLivePhotoOnDroid( Future<void> _saveLivePhotoOnDroid(
io.File image, io.File video, File enteFile) async { io.File image,
io.File video,
File enteFile,
) async {
debugPrint("Downloading LivePhoto on Droid"); debugPrint("Downloading LivePhoto on Droid");
AssetEntity savedAsset = await PhotoManager.editor AssetEntity savedAsset = await PhotoManager.editor
.saveImageWithPath(image.path, title: enteFile.title); .saveImageWithPath(image.path, title: enteFile.title);

View file

@ -1,5 +1,3 @@
// @dart=2.9
import 'dart:io' as io; import 'dart:io' as io;
import 'package:exif/exif.dart'; import 'package:exif/exif.dart';
@ -29,18 +27,16 @@ Future<Map<String, IfdTag>> getExif(File file) async {
} }
} }
Future<DateTime> getCreationTimeFromEXIF(io.File file) async { Future<DateTime?> getCreationTimeFromEXIF(io.File file) async {
try { try {
final exif = await readExifFromFile(file); final exif = await readExifFromFile(file);
if (exif != null) { final exifTime = exif.containsKey(kDateTimeOriginal)
final exifTime = exif.containsKey(kDateTimeOriginal) ? exif[kDateTimeOriginal]!.printable
? exif[kDateTimeOriginal].printable : exif.containsKey(kImageDateTime)
: exif.containsKey(kImageDateTime) ? exif[kImageDateTime]!.printable
? exif[kImageDateTime].printable : null;
: null; if (exifTime != null && exifTime != kEmptyExifDateTime) {
if (exifTime != null && exifTime != kEmptyExifDateTime) { return DateFormat(kExifDateTimePattern).parse(exifTime);
return DateFormat(kExifDateTimePattern).parse(exifTime);
}
} }
} catch (e) { } catch (e) {
_logger.severe("failed to getCreationTimeFromEXIF", e); _logger.severe("failed to getCreationTimeFromEXIF", e);

View file

@ -188,7 +188,8 @@ class FileUploader {
_queue.remove(id).completer.completeError(reason); _queue.remove(id).completer.completeError(reason);
} }
_logger.info( _logger.info(
'number of enteries removed from queue ${uploadsToBeRemoved.length}'); 'number of enteries removed from queue ${uploadsToBeRemoved.length}',
);
_totalCountInUploadSession -= uploadsToBeRemoved.length; _totalCountInUploadSession -= uploadsToBeRemoved.length;
} }