fixed some lint issues (effective dart style)

This commit is contained in:
Thibault Deckers 2020-07-26 02:21:51 +09:00
parent 2ed7851d7d
commit a48937795e
31 changed files with 61 additions and 67 deletions

View file

@ -34,7 +34,7 @@ class MimeFilter extends CollectionFilter {
_label ??= lowMime.split('/')[0].toUpperCase();
} else {
_filter = (entry) => entry.mimeType == lowMime;
if (lowMime == MimeTypes.SVG) {
if (lowMime == MimeTypes.svg) {
_label = 'SVG';
}
_label ??= lowMime.split('/')[1].toUpperCase();

View file

@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart';
class QueryFilter extends CollectionFilter {
static const type = 'query';
static final exactRegex = RegExp('^"(.*)"\$');
static final RegExp exactRegex = RegExp('^"(.*)"\$');
final String query;
final bool colorful;
@ -39,7 +39,7 @@ class QueryFilter extends CollectionFilter {
bool get isUnique => false;
@override
String get label => '${query}';
String get label => '$query';
@override
Widget iconBuilder(BuildContext context, double size, {bool showGenericIcon = true}) => Icon(AIcons.text, size: size);

View file

@ -152,10 +152,10 @@ class ImageEntry {
bool get isFavourite => favourites.isFavourite(this);
bool get isSvg => mimeType == MimeTypes.SVG;
bool get isSvg => mimeType == MimeTypes.svg;
// guess whether this is a photo, according to file type (used as a hint to e.g. display megapixels)
bool get isPhoto => [MimeTypes.HEIC, MimeTypes.HEIF, MimeTypes.JPEG].contains(mimeType);
bool get isPhoto => [MimeTypes.heic, MimeTypes.heif, MimeTypes.jpeg].contains(mimeType);
bool get isVideo => mimeType.startsWith('video');
@ -167,7 +167,7 @@ class ImageEntry {
bool get canPrint => !isVideo;
bool get canRotate => canEdit && (mimeType == MimeTypes.JPEG || mimeType == MimeTypes.PNG);
bool get canRotate => canEdit && (mimeType == MimeTypes.jpeg || mimeType == MimeTypes.png);
bool get rotated => ((isVideo && isCatalogued) ? _catalogMetadata.videoRotation : orientationDegrees) % 180 == 90;
@ -270,7 +270,7 @@ class ImageEntry {
final coordinates = Coordinates(latitude, longitude);
try {
final call = () => Geocoder.local.findAddressesFromCoordinates(coordinates);
Future<List<Address>> call() => Geocoder.local.findAddressesFromCoordinates(coordinates);
final addresses = await (background
? servicePolicy.call(
call,

View file

@ -1,15 +1,15 @@
class MimeTypes {
static const String ANY_IMAGE = 'image/*';
static const String GIF = 'image/gif';
static const String HEIC = 'image/heic';
static const String HEIF = 'image/heif';
static const String JPEG = 'image/jpeg';
static const String PNG = 'image/png';
static const String SVG = 'image/svg+xml';
static const String WEBP = 'image/webp';
static const String anyImage = 'image/*';
static const String gif = 'image/gif';
static const String heic = 'image/heic';
static const String heif = 'image/heif';
static const String jpeg = 'image/jpeg';
static const String png = 'image/png';
static const String svg = 'image/svg+xml';
static const String webp = 'image/webp';
static const String ANY_VIDEO = 'video/*';
static const String AVI = 'video/avi';
static const String MP2T = 'video/mp2t'; // .m2ts
static const String MP4 = 'video/mp4';
static const String anyVideo = 'video/*';
static const String avi = 'video/avi';
static const String mp2t = 'video/mp2t'; // .m2ts
static const String mp4 = 'video/mp4';
}

View file

@ -168,8 +168,8 @@ class CollectionLens with ChangeNotifier, CollectionActivityMixin, CollectionSel
]);
break;
case SortFactor.name:
final byAlbum = groupBy(_filteredEntries, (ImageEntry entry) => entry.directory);
final compare = (a, b) {
final byAlbum = groupBy(_filteredEntries, (entry) => entry.directory);
int compare(a, b) {
final ua = source.getUniqueAlbumName(a);
final ub = source.getUniqueAlbumName(b);
final c = compareAsciiUpperCase(ua, ub);

View file

@ -75,7 +75,7 @@ mixin LocationMixin on SourceBase {
void updateLocations() {
final locations = rawEntries.where((entry) => entry.isLocated).map((entry) => entry.addressDetails).toList();
final lister = (String Function(AddressDetails a) f) => List<String>.unmodifiable(locations.map(f).where((s) => s != null && s.isNotEmpty).toSet().toList()..sort(compareAsciiUpperCase));
List<String> lister(String Function(AddressDetails a) f) => List<String>.unmodifiable(locations.map(f).where((s) => s != null && s.isNotEmpty).toSet().toList()..sort(compareAsciiUpperCase));
sortedCountries = lister((address) => '${address.countryName};${address.countryCode}');
sortedPlaces = lister((address) => address.place);

View file

@ -140,7 +140,7 @@ class ImageFileService {
try {
return opChannel.receiveBroadcastStream(<String, dynamic>{
'op': 'delete',
'entries': entries.map((entry) => _toPlatformEntryMap(entry)).toList(),
'entries': entries.map(_toPlatformEntryMap).toList(),
}).map((event) => ImageOpEvent.fromMap(event));
} on PlatformException catch (e) {
debugPrint('delete failed with code=${e.code}, exception=${e.message}, details=${e.details}');
@ -153,7 +153,7 @@ class ImageFileService {
try {
return opChannel.receiveBroadcastStream(<String, dynamic>{
'op': 'move',
'entries': entries.map((entry) => _toPlatformEntryMap(entry)).toList(),
'entries': entries.map(_toPlatformEntryMap).toList(),
'copy': copy,
'destinationPath': destinationAlbum,
}).map((event) => MoveOpEvent.fromMap(event));

View file

@ -26,7 +26,7 @@ class MetadataService {
static Future<CatalogMetadata> getCatalogMetadata(ImageEntry entry, {bool background = false}) async {
if (entry.isSvg) return null;
final call = () async {
Future<CatalogMetadata> call() async {
try {
// return map with:
// 'mimeType': MIME type as reported by metadata extractors, not Media Store (string)

View file

@ -30,5 +30,5 @@ class Durations {
static const collectionScrollMonitoringTimerDelay = Duration(milliseconds: 100);
static const collectionScalingCompleteNotificationDelay = Duration(milliseconds: 300);
static const videoProgressTimerInterval = Duration(milliseconds: 300);
static var staggeredAnimationDelay = Durations.staggeredAnimation ~/ 6 * timeDilation;
static Duration staggeredAnimationDelay = Durations.staggeredAnimation ~/ 6 * timeDilation;
}

View file

@ -155,7 +155,7 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
animation: collection.selectionChangeNotifier,
builder: (context, child) {
final count = collection.selection.length;
return Text(Intl.plural(count, zero: 'Select items', one: '${count} item', other: '${count} items'));
return Text(Intl.plural(count, zero: 'Select items', one: '$count item', other: '$count items'));
},
);
}

View file

@ -62,7 +62,7 @@ class _GridScaleGestureDetectorState extends State<GridScaleGestureDetector> {
scrollableBox.hitTest(result, position: details.localFocalPoint);
// find `RenderObject`s at the gesture focal point
final firstOf = <T>(BoxHitTestResult result) => result.path.firstWhere((el) => el.target is T, orElse: () => null)?.target as T;
T firstOf<T>(BoxHitTestResult result) => result.path.firstWhere((el) => el.target is T, orElse: () => null)?.target as T;
final renderMetaData = firstOf<RenderMetaData>(result);
// abort if we cannot find an image to show on overlay
if (renderMetaData == null) return;

View file

@ -57,7 +57,7 @@ class ImageSearchDelegate extends SearchDelegate<CollectionFilter> {
@override
Widget buildSuggestions(BuildContext context) {
final upQuery = query.trim().toUpperCase();
final containQuery = (String s) => s.toUpperCase().contains(upQuery);
bool containQuery(String s) => s.toUpperCase().contains(upQuery);
return SafeArea(
child: ValueListenableBuilder<String>(
valueListenable: expandedSectionNotifier,
@ -70,10 +70,10 @@ class ImageSearchDelegate extends SearchDelegate<CollectionFilter> {
filters: [
_buildQueryFilter(false),
FavouriteFilter(),
MimeFilter(MimeTypes.ANY_IMAGE),
MimeFilter(MimeTypes.ANY_VIDEO),
MimeFilter(MimeTypes.anyImage),
MimeFilter(MimeTypes.anyVideo),
MimeFilter(MimeFilter.animated),
MimeFilter(MimeTypes.SVG),
MimeFilter(MimeTypes.svg),
].where((f) => f != null && containQuery(f.label)),
),
StreamBuilder(

View file

@ -220,7 +220,7 @@ class _CollectionScrollViewState extends State<CollectionScrollView> {
);
}
debugPrint('collection.filters=${collection.filters}');
if (collection.filters.any((filter) => filter is MimeFilter && filter.mime == MimeTypes.ANY_VIDEO)) {
if (collection.filters.any((filter) => filter is MimeFilter && filter.mime == MimeTypes.anyVideo)) {
return const EmptyContent(
icon: AIcons.video,
text: 'No videos',

View file

@ -85,7 +85,7 @@ class _AppDrawerState extends State<AppDrawer> {
source: source,
leading: const Icon(AIcons.video),
title: 'Videos',
filter: MimeFilter(MimeTypes.ANY_VIDEO),
filter: MimeFilter(MimeTypes.anyVideo),
);
final favouriteEntry = _FilteredCollectionNavTile(
source: source,

View file

@ -118,7 +118,7 @@ class EntryActionDelegate with FeedbackMixin, PermissionAwareMixin {
Future<void> _showDeleteDialog(BuildContext context, ImageEntry entry) async {
final confirmed = await showDialog<bool>(
context: context,
builder: (BuildContext context) {
builder: (context) {
return AlertDialog(
content: const Text('Are you sure?'),
actions: [

View file

@ -21,7 +21,7 @@ mixin PermissionAwareMixin {
final confirmed = await showDialog<bool>(
context: context,
builder: (BuildContext context) {
builder: (context) {
return AlertDialog(
title: const Text('Storage Volume Access'),
content: Text('Please select the $dirDisplayName directory of “$volumeDescription” in the next screen, so that this app can access it and complete your request.'),

View file

@ -116,10 +116,10 @@ class SelectionActionDelegate with FeedbackMixin, PermissionAwareMixin {
final selectionCount = selection.length;
if (movedCount < selectionCount) {
final count = selectionCount - movedCount;
showFeedback(context, 'Failed to move ${Intl.plural(count, one: '${count} item', other: '${count} items')}');
showFeedback(context, 'Failed to move ${Intl.plural(count, one: '$count item', other: '$count items')}');
} else {
final count = movedCount;
showFeedback(context, '${copy ? 'Copied' : 'Moved'} ${Intl.plural(count, one: '${count} item', other: '${count} items')}');
showFeedback(context, '${copy ? 'Copied' : 'Moved'} ${Intl.plural(count, one: '$count item', other: '$count items')}');
}
if (movedCount > 0) {
final fromAlbums = <String>{};
@ -187,9 +187,9 @@ class SelectionActionDelegate with FeedbackMixin, PermissionAwareMixin {
final confirmed = await showDialog<bool>(
context: context,
builder: (BuildContext context) {
builder: (context) {
return AlertDialog(
content: Text('Are you sure you want to delete ${Intl.plural(count, one: 'this item', other: 'these ${count} items')}?'),
content: Text('Are you sure you want to delete ${Intl.plural(count, one: 'this item', other: 'these $count items')}?'),
actions: [
FlatButton(
onPressed: () => Navigator.pop(context),
@ -217,7 +217,7 @@ class SelectionActionDelegate with FeedbackMixin, PermissionAwareMixin {
final selectionCount = selection.length;
if (deletedCount < selectionCount) {
final count = selectionCount - deletedCount;
showFeedback(context, 'Failed to delete ${Intl.plural(count, one: '${count} item', other: '${count} items')}');
showFeedback(context, 'Failed to delete ${Intl.plural(count, one: '$count item', other: '$count items')}');
}
if (deletedCount > 0) {
collection.source.removeEntries(selection.where((e) => deletedUris.contains(e.uri)));
@ -242,9 +242,9 @@ class SelectionActionDelegate with FeedbackMixin, PermissionAwareMixin {
// do not handle completion inside `StreamBuilder`
// as it could be called multiple times
final onComplete = () => _hideOpReportOverlay().then((_) => onDone(processed));
Future<void> onComplete() => _hideOpReportOverlay().then((_) => onDone(processed));
opStream.listen(
(event) => processed.add(event),
processed.add,
onError: (error) {
debugPrint('_showOpReport error=$error');
onComplete();

View file

@ -51,7 +51,7 @@ class MediaStoreSource extends CollectionSource {
var refreshCount = 10;
const refreshCountMax = 1000;
final allNewEntries = <ImageEntry>[], pendingNewEntries = <ImageEntry>[];
final addPendingEntries = () {
void addPendingEntries() {
allNewEntries.addAll(pendingNewEntries);
addAll(pendingNewEntries);
pendingNewEntries.clear();

View file

@ -54,7 +54,7 @@ class ThumbnailProvider extends ImageProvider<ThumbnailProviderKey> {
}
@override
void resolveStreamForKey(ImageConfiguration configuration, ImageStream stream, ThumbnailProviderKey key, handleError) {
void resolveStreamForKey(ImageConfiguration configuration, ImageStream stream, ThumbnailProviderKey key, ImageErrorListener handleError) {
ImageFileService.resumeThumbnail(_cancellationKey);
super.resolveStreamForKey(configuration, stream, key, handleError);
}

View file

@ -32,13 +32,7 @@ ScrollThumbBuilder avesScrollThumbBuilder({
clipper: ArrowClipper(),
),
);
return (
Color backgroundColor,
Animation<double> thumbAnimation,
Animation<double> labelAnimation,
double height, {
Widget labelText,
}) {
return (backgroundColor, thumbAnimation, labelAnimation, height, {labelText}) {
return DraggableScrollbar.buildScrollThumbAndLabel(
scrollThumb: scrollThumb,
backgroundColor: backgroundColor,

View file

@ -12,7 +12,7 @@ class TransitionImage extends StatefulWidget {
final ImageProvider image;
final double width, height;
final ValueListenable<double> animation;
final gaplessPlayback = false;
final bool gaplessPlayback = false;
const TransitionImage({
@required this.image,

View file

@ -135,7 +135,7 @@ class DebugPageState extends State<DebugPage> {
),
const SizedBox(width: 8),
RaisedButton(
onPressed: () => ImageFileService.clearSizedThumbnailDiskCache(),
onPressed: ImageFileService.clearSizedThumbnailDiskCache,
child: const Text('Clear'),
),
],

View file

@ -61,7 +61,7 @@ class ImageView extends StatelessWidget {
// if the image is already in the cache it will show the final image, otherwise the thumbnail
// in any case, we should use `Center` + `AspectRatio` + `Fill` so that the transition image
// appears as the final image with `PhotoViewComputedScale.contained` for `initialScale`
final loadingBuilder = (BuildContext context, ImageProvider imageProvider) {
Widget loadingBuilder(BuildContext context, ImageProvider imageProvider) {
return Center(
child: AspectRatio(
// enforce original aspect ratio, as some thumbnails aspect ratios slightly differ

View file

@ -53,7 +53,7 @@ class BasicSection extends StatelessWidget {
final tags = entry.xmpSubjects..sort(compareAsciiUpperCase);
final album = entry.directory;
final filters = [
if (entry.isVideo) MimeFilter(MimeTypes.ANY_VIDEO),
if (entry.isVideo) MimeFilter(MimeTypes.anyVideo),
if (entry.isAnimated) MimeFilter(MimeFilter.animated),
if (album != null) AlbumFilter(album, collection?.source?.getUniqueAlbumName(album)),
...tags.map((tag) => TagFilter(tag)),

View file

@ -165,7 +165,7 @@ class SectionRow extends StatelessWidget {
@override
Widget build(BuildContext context) {
const dim = 32.0;
final buildDivider = () => const SizedBox(
Widget buildDivider() => const SizedBox(
width: dim,
child: Divider(
thickness: AvesFilterChip.outlineWidth,

View file

@ -151,7 +151,7 @@ class _TopOverlayRow extends StatelessWidget {
Widget _buildOverlayButton(EntryAction action) {
Widget child;
final onPressed = () => onActionSelected?.call(action);
void onPressed() => onActionSelected?.call(action);
switch (action) {
case EntryAction.toggleFavourite:
child = _FavouriteToggler(

View file

@ -98,7 +98,7 @@ class VideoControlOverlayState extends State<VideoControlOverlay> with SingleTic
@override
Widget build(BuildContext context) {
final mq = context.select((MediaQueryData mq) => Tuple3(mq.size.width, mq.viewInsets, mq.viewPadding));
final mq = context.select((mq) => Tuple3(mq.size.width, mq.viewInsets, mq.viewPadding));
final mqWidth = mq.item1;
final mqViewInsets = mq.item2;
final mqViewPadding = mq.item3;
@ -164,17 +164,17 @@ class VideoControlOverlayState extends State<VideoControlOverlay> with SingleTic
child: BlurredRRect(
borderRadius: progressBarBorderRadius,
child: GestureDetector(
onTapDown: (TapDownDetails details) {
onTapDown: (details) {
_seekFromTap(details.globalPosition);
},
onHorizontalDragStart: (DragStartDetails details) {
onHorizontalDragStart: (details) {
_playingOnDragStart = isPlaying;
if (_playingOnDragStart) controller.pause();
},
onHorizontalDragUpdate: (DragUpdateDetails details) {
onHorizontalDragUpdate: (details) {
_seekFromTap(details.globalPosition);
},
onHorizontalDragEnd: (DragEndDetails details) {
onHorizontalDragEnd: (details) {
if (_playingOnDragStart) controller.play();
},
child: Container(

View file

@ -68,7 +68,7 @@ class _HomePageState extends State<HomePage> {
// TODO TLAD apply pick mimetype(s)
// some apps define multiple types, separated by a space (maybe other signs too, like `,` `;`?)
String pickMimeTypes = intentData['mimeType'];
debugPrint('pick mimeType=' + pickMimeTypes);
debugPrint('pick mimeType=$pickMimeTypes');
break;
}
}

View file

@ -67,7 +67,7 @@ class FilterTable extends StatelessWidget {
center: Text(NumberFormat.percentPattern().format(percent)),
),
Text(
'${count}',
'$count',
style: const TextStyle(color: Colors.white70),
textAlign: TextAlign.end,
),

View file

@ -158,7 +158,7 @@ class StatsPage extends StatelessWidget {
),
Center(
child: Text(
'${sum}\n${label(sum)}',
'$sum\n${label(sum)}',
textAlign: TextAlign.center,
),
),

View file

@ -35,7 +35,7 @@ class _WelcomePageState extends State<WelcomePage> {
padding: const EdgeInsets.all(16.0),
child: FutureBuilder(
future: _termsLoader,
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
builder: (context, AsyncSnapshot<String> snapshot) {
if (snapshot.hasError || snapshot.connectionState != ConnectionState.done) return const SizedBox.shrink();
final terms = snapshot.data;
return Column(