mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
chore: more dart lints (#30665)
Some checks failed
CLI Build / CLI Publish (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Docker / pre-job (push) Has been cancelled
Docs build / pre-job (push) Has been cancelled
Zizmor / Zizmor (push) Has been cancelled
Static Code Analysis / pre-job (push) Has been cancelled
Test / pre-job (push) Has been cancelled
Test / ShellCheck (push) Has been cancelled
Test / OpenAPI Clients (push) Has been cancelled
Test / SQL Schema Checks (push) Has been cancelled
CLI Build / Docker (push) Has been cancelled
Docker / Re-Tag ML (push) Has been cancelled
Docker / Re-Tag Server (push) Has been cancelled
Docker / Build and Push ML (push) Has been cancelled
Docker / Build and Push Server (push) Has been cancelled
Docker / Mirror to Docker Hub (push) Has been cancelled
Docker / Docker Build & Push Server Success (push) Has been cancelled
Docker / Docker Build & Push ML Success (push) Has been cancelled
Docs build / Docs Build (push) Has been cancelled
Static Code Analysis / Run Dart Code Analysis (push) Has been cancelled
Test / Scripts unit tests (push) Has been cancelled
Test / Test & Lint Server (push) Has been cancelled
Test / Unit Test CLI (push) Has been cancelled
Test / Unit Test CLI (Windows) (push) Has been cancelled
Test / Lint Web (push) Has been cancelled
Test / Test Web (push) Has been cancelled
Test / Test i18n (push) Has been cancelled
Test / End-to-End Lint (push) Has been cancelled
Test / Medium Tests (Server) (push) Has been cancelled
Test / End-to-End Tests (Server & CLI) (push) Has been cancelled
Test / End-to-End Tests (Web) (push) Has been cancelled
Test / End-to-End Tests Success (push) Has been cancelled
Test / Unit Test Mobile (push) Has been cancelled
Test / Unit Test ML (push) Has been cancelled
Test / .github Files Formatting (push) Has been cancelled
Some checks failed
CLI Build / CLI Publish (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Docker / pre-job (push) Has been cancelled
Docs build / pre-job (push) Has been cancelled
Zizmor / Zizmor (push) Has been cancelled
Static Code Analysis / pre-job (push) Has been cancelled
Test / pre-job (push) Has been cancelled
Test / ShellCheck (push) Has been cancelled
Test / OpenAPI Clients (push) Has been cancelled
Test / SQL Schema Checks (push) Has been cancelled
CLI Build / Docker (push) Has been cancelled
Docker / Re-Tag ML (push) Has been cancelled
Docker / Re-Tag Server (push) Has been cancelled
Docker / Build and Push ML (push) Has been cancelled
Docker / Build and Push Server (push) Has been cancelled
Docker / Mirror to Docker Hub (push) Has been cancelled
Docker / Docker Build & Push Server Success (push) Has been cancelled
Docker / Docker Build & Push ML Success (push) Has been cancelled
Docs build / Docs Build (push) Has been cancelled
Static Code Analysis / Run Dart Code Analysis (push) Has been cancelled
Test / Scripts unit tests (push) Has been cancelled
Test / Test & Lint Server (push) Has been cancelled
Test / Unit Test CLI (push) Has been cancelled
Test / Unit Test CLI (Windows) (push) Has been cancelled
Test / Lint Web (push) Has been cancelled
Test / Test Web (push) Has been cancelled
Test / Test i18n (push) Has been cancelled
Test / End-to-End Lint (push) Has been cancelled
Test / Medium Tests (Server) (push) Has been cancelled
Test / End-to-End Tests (Server & CLI) (push) Has been cancelled
Test / End-to-End Tests (Web) (push) Has been cancelled
Test / End-to-End Tests Success (push) Has been cancelled
Test / Unit Test Mobile (push) Has been cancelled
Test / Unit Test ML (push) Has been cancelled
Test / .github Files Formatting (push) Has been cancelled
The lints are regrouped and sorted. Also, added the following new lints: - unnecessary_ignore - parameter_assignments - avoid_unused_constructor_parameters - tighten_type_of_initializing_formals - only_throw_errors - deprecated_consistency - unnecessary_statements Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
bd55f7e73a
commit
ffc83eae36
24 changed files with 112 additions and 137 deletions
|
|
@ -26,52 +26,59 @@ linter:
|
||||||
# producing the lint.
|
# producing the lint.
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
# Formatting
|
# Correctness
|
||||||
avoid_print: true
|
always_declare_return_types: true
|
||||||
require_trailing_commas: true
|
avoid_type_to_string: true
|
||||||
unrelated_type_equality_checks: true
|
avoid_unused_constructor_parameters: true
|
||||||
prefer_const_constructors: true
|
avoid_void_async: true
|
||||||
always_use_package_imports: true
|
cancel_subscriptions: true
|
||||||
always_put_control_body_on_new_line: true
|
cast_nullable_to_non_nullable: true
|
||||||
|
close_sinks: true
|
||||||
|
collection_methods_unrelated_type: true
|
||||||
|
deprecated_consistency: true
|
||||||
|
discarded_futures: true
|
||||||
|
no_adjacent_strings_in_list: true
|
||||||
|
no_self_assignments: true
|
||||||
|
noop_primitive_operations: true
|
||||||
|
only_throw_errors: true
|
||||||
|
parameter_assignments: true
|
||||||
|
throw_in_finally: true
|
||||||
|
tighten_type_of_initializing_formals: true
|
||||||
|
unawaited_futures: true
|
||||||
|
unnecessary_ignore: true
|
||||||
unnecessary_null_checks: true
|
unnecessary_null_checks: true
|
||||||
unnecessary_parenthesis: true
|
unnecessary_statements: true
|
||||||
prefer_final_locals: true
|
unrelated_type_equality_checks: true
|
||||||
|
|
||||||
|
# Performance
|
||||||
|
avoid_slow_async_io: true
|
||||||
|
prefer_const_constructors: true
|
||||||
prefer_const_declarations: true
|
prefer_const_declarations: true
|
||||||
prefer_const_literals_to_create_immutables: true
|
prefer_const_literals_to_create_immutables: true
|
||||||
use_super_parameters: true
|
|
||||||
directives_ordering: true
|
|
||||||
no_leading_underscores_for_local_identifiers: true
|
|
||||||
always_declare_return_types: true
|
|
||||||
avoid_void_async: true
|
|
||||||
noop_primitive_operations: true
|
|
||||||
use_named_constants: true
|
|
||||||
combinators_ordering: true
|
|
||||||
avoid_multiple_declarations_per_line: true
|
|
||||||
unnecessary_breaks: true
|
|
||||||
|
|
||||||
# Correctness
|
|
||||||
no_adjacent_strings_in_list: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
unawaited_futures: true
|
|
||||||
discarded_futures: true
|
|
||||||
no_self_assignments: true
|
|
||||||
throw_in_finally: true
|
|
||||||
collection_methods_unrelated_type: true
|
|
||||||
cast_nullable_to_non_nullable: true
|
|
||||||
|
|
||||||
# Known issues
|
|
||||||
avoid_slow_async_io: true
|
|
||||||
avoid_type_to_string: true
|
|
||||||
|
|
||||||
# Flutter specific
|
# Flutter specific
|
||||||
use_build_context_synchronously: true
|
avoid_unnecessary_containers: true
|
||||||
sized_box_for_whitespace: true
|
sized_box_for_whitespace: true
|
||||||
|
use_build_context_synchronously: true
|
||||||
use_colored_box: true
|
use_colored_box: true
|
||||||
use_decorated_box: true
|
use_decorated_box: true
|
||||||
avoid_unnecessary_containers: true
|
|
||||||
use_full_hex_values_for_flutter_colors: true
|
use_full_hex_values_for_flutter_colors: true
|
||||||
|
|
||||||
|
# Style
|
||||||
|
always_put_control_body_on_new_line: true
|
||||||
|
always_use_package_imports: true
|
||||||
|
avoid_multiple_declarations_per_line: true
|
||||||
|
avoid_print: true
|
||||||
|
combinators_ordering: true
|
||||||
|
directives_ordering: true
|
||||||
|
no_leading_underscores_for_local_identifiers: true
|
||||||
|
prefer_final_locals: true
|
||||||
|
require_trailing_commas: true
|
||||||
|
unnecessary_breaks: true
|
||||||
|
unnecessary_parenthesis: true
|
||||||
|
use_named_constants: true
|
||||||
|
use_super_parameters: true
|
||||||
|
|
||||||
# Additional information about this file can be found at
|
# Additional information about this file can be found at
|
||||||
# https://dart.dev/guides/language/analysis-options
|
# https://dart.dev/guides/language/analysis-options
|
||||||
analyzer:
|
analyzer:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
|
||||||
import 'package:background_downloader/background_downloader.dart';
|
import 'package:background_downloader/background_downloader.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
enum LivePhotosPart { video, image }
|
enum LivePhotosPart { video, image }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import 'dart:async';
|
||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/domain/models/person.model.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/string_extensions.dart';
|
import 'package:immich_mobile/extensions/string_extensions.dart';
|
||||||
import 'package:immich_mobile/generated/translations.g.dart';
|
import 'package:immich_mobile/generated/translations.g.dart';
|
||||||
|
|
@ -65,12 +66,15 @@ class _DriftPeopleCollectionPageState extends ConsumerState<DriftPeopleCollectio
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: people.when(
|
child: people.when(
|
||||||
data: (people) {
|
data: (people) {
|
||||||
|
final List<Person> filtered;
|
||||||
if (_search != null) {
|
if (_search != null) {
|
||||||
people = people.where((person) {
|
filtered = people.where((person) {
|
||||||
return person.name.toLowerCase().removeDiacritics().contains(
|
return person.name.toLowerCase().removeDiacritics().contains(
|
||||||
_search!.toLowerCase().removeDiacritics(),
|
_search!.toLowerCase().removeDiacritics(),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
} else {
|
||||||
|
filtered = people;
|
||||||
}
|
}
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
|
@ -79,9 +83,9 @@ class _DriftPeopleCollectionPageState extends ConsumerState<DriftPeopleCollectio
|
||||||
mainAxisSpacing: isPortrait && isTablet ? 36 : 0,
|
mainAxisSpacing: isPortrait && isTablet ? 36 : 0,
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 32),
|
padding: const EdgeInsets.symmetric(vertical: 32),
|
||||||
itemCount: people.length,
|
itemCount: filtered.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final person = people[index];
|
final person = filtered[index];
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
key: ValueKey(person.id),
|
key: ValueKey(person.id),
|
||||||
|
|
|
||||||
|
|
@ -134,16 +134,19 @@ class _PlaceList extends ConsumerWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
data: (places) {
|
data: (places) {
|
||||||
|
final List<(String, String)> filtered;
|
||||||
if (search.value != null) {
|
if (search.value != null) {
|
||||||
places = places.where((place) {
|
filtered = places.where((place) {
|
||||||
return place.$1.toLowerCase().contains(search.value!.toLowerCase());
|
return place.$1.toLowerCase().contains(search.value!.toLowerCase());
|
||||||
}).toList();
|
}).toList();
|
||||||
|
} else {
|
||||||
|
filtered = places;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SliverList.builder(
|
return SliverList.builder(
|
||||||
itemCount: places.length,
|
itemCount: filtered.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final place = places[index];
|
final place = filtered[index];
|
||||||
return _PlaceTile(place: place);
|
return _PlaceTile(place: place);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
// ignore_for_file: require_trailing_commas
|
|
||||||
|
|
||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:immich_mobile/domain/models/events.model.dart';
|
import 'package:immich_mobile/domain/models/events.model.dart';
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ class Scrubber extends ConsumerStatefulWidget {
|
||||||
|
|
||||||
Scrubber({
|
Scrubber({
|
||||||
super.key,
|
super.key,
|
||||||
Key? scrollThumbKey,
|
|
||||||
required this.layoutSegments,
|
required this.layoutSegments,
|
||||||
required this.timelineHeight,
|
required this.timelineHeight,
|
||||||
this.topPadding = 0,
|
this.topPadding = 0,
|
||||||
|
|
|
||||||
|
|
@ -22,40 +22,25 @@ class BackupAlbumNotifier extends StateNotifier<List<LocalAlbum>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> selectAlbum(LocalAlbum album) async {
|
Future<void> selectAlbum(LocalAlbum album) async {
|
||||||
album = album.copyWith(backupSelection: BackupSelection.selected);
|
final selectedAlbum = album.copyWith(backupSelection: BackupSelection.selected);
|
||||||
await _localAlbumService.update(album);
|
await _localAlbumService.update(selectedAlbum);
|
||||||
|
|
||||||
state = state
|
state = state.map((currentAlbum) => currentAlbum.id == selectedAlbum.id ? selectedAlbum : currentAlbum).toList();
|
||||||
.map(
|
|
||||||
(currentAlbum) => currentAlbum.id == album.id
|
|
||||||
? currentAlbum.copyWith(backupSelection: BackupSelection.selected)
|
|
||||||
: currentAlbum,
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> deselectAlbum(LocalAlbum album) async {
|
Future<void> deselectAlbum(LocalAlbum album) async {
|
||||||
album = album.copyWith(backupSelection: BackupSelection.none);
|
final deselectedAlbum = album.copyWith(backupSelection: BackupSelection.none);
|
||||||
await _localAlbumService.update(album);
|
await _localAlbumService.update(deselectedAlbum);
|
||||||
|
|
||||||
state = state
|
state = state
|
||||||
.map(
|
.map((currentAlbum) => currentAlbum.id == deselectedAlbum.id ? deselectedAlbum : currentAlbum)
|
||||||
(currentAlbum) =>
|
|
||||||
currentAlbum.id == album.id ? currentAlbum.copyWith(backupSelection: BackupSelection.none) : currentAlbum,
|
|
||||||
)
|
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> excludeAlbum(LocalAlbum album) async {
|
Future<void> excludeAlbum(LocalAlbum album) async {
|
||||||
album = album.copyWith(backupSelection: BackupSelection.excluded);
|
final excludedAlbum = album.copyWith(backupSelection: BackupSelection.excluded);
|
||||||
await _localAlbumService.update(album);
|
await _localAlbumService.update(excludedAlbum);
|
||||||
|
|
||||||
state = state
|
state = state.map((currentAlbum) => currentAlbum.id == excludedAlbum.id ? excludedAlbum : currentAlbum).toList();
|
||||||
.map(
|
|
||||||
(currentAlbum) => currentAlbum.id == album.id
|
|
||||||
? currentAlbum.copyWith(backupSelection: BackupSelection.excluded)
|
|
||||||
: currentAlbum,
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,6 @@ import 'package:immich_mobile/presentation/pages/profile/profile_picture_crop.pa
|
||||||
import 'package:immich_mobile/presentation/pages/search/drift_search.page.dart';
|
import 'package:immich_mobile/presentation/pages/search/drift_search.page.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.page.dart';
|
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.page.dart';
|
||||||
import 'package:immich_mobile/providers/api.provider.dart';
|
import 'package:immich_mobile/providers/api.provider.dart';
|
||||||
import 'package:immich_mobile/providers/gallery_permission.provider.dart';
|
|
||||||
import 'package:immich_mobile/routing/auth_guard.dart';
|
import 'package:immich_mobile/routing/auth_guard.dart';
|
||||||
import 'package:immich_mobile/routing/duplicate_guard.dart';
|
import 'package:immich_mobile/routing/duplicate_guard.dart';
|
||||||
import 'package:immich_mobile/routing/locked_guard.dart';
|
import 'package:immich_mobile/routing/locked_guard.dart';
|
||||||
|
|
@ -88,7 +87,6 @@ final appRouterProvider = Provider(
|
||||||
(ref) => AppRouter(
|
(ref) => AppRouter(
|
||||||
ref.watch(apiServiceProvider),
|
ref.watch(apiServiceProvider),
|
||||||
ref.watch(authServiceProvider),
|
ref.watch(authServiceProvider),
|
||||||
ref.watch(galleryPermissionNotifier.notifier),
|
|
||||||
ref.watch(secureStorageServiceProvider),
|
ref.watch(secureStorageServiceProvider),
|
||||||
ref.watch(localAuthServiceProvider),
|
ref.watch(localAuthServiceProvider),
|
||||||
),
|
),
|
||||||
|
|
@ -103,7 +101,6 @@ class AppRouter extends RootStackRouter {
|
||||||
AppRouter(
|
AppRouter(
|
||||||
ApiService apiService,
|
ApiService apiService,
|
||||||
AuthService authService,
|
AuthService authService,
|
||||||
GalleryPermissionNotifier galleryPermissionNotifier,
|
|
||||||
SecureStorageService secureStorageService,
|
SecureStorageService secureStorageService,
|
||||||
LocalAuthService localAuthService,
|
LocalAuthService localAuthService,
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -113,12 +113,10 @@ class ApiService {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _isEndpointAvailable(String serverUrl) async {
|
Future<bool> _isEndpointAvailable(String serverUrl) async {
|
||||||
if (!serverUrl.endsWith('/api')) {
|
final endpoint = serverUrl.endsWith('/api') ? serverUrl : '$serverUrl/api';
|
||||||
serverUrl += '/api';
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setEndpoint(serverUrl);
|
setEndpoint(endpoint);
|
||||||
await serverInfoApi.pingServer().timeout(const Duration(seconds: 5));
|
await serverInfoApi.pingServer().timeout(const Duration(seconds: 5));
|
||||||
} on TimeoutException catch (_) {
|
} on TimeoutException catch (_) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,8 @@ class PhotoViewGallery extends StatefulWidget {
|
||||||
/// The builder must return a [PhotoViewGalleryPageOptions].
|
/// The builder must return a [PhotoViewGalleryPageOptions].
|
||||||
const PhotoViewGallery.builder({
|
const PhotoViewGallery.builder({
|
||||||
super.key,
|
super.key,
|
||||||
required this.itemCount,
|
required int this.itemCount,
|
||||||
required this.builder,
|
required PhotoViewGalleryBuilder this.builder,
|
||||||
this.loadingBuilder,
|
this.loadingBuilder,
|
||||||
this.backgroundDecoration,
|
this.backgroundDecoration,
|
||||||
this.wantKeepAlive = false,
|
this.wantKeepAlive = false,
|
||||||
|
|
@ -145,9 +145,7 @@ class PhotoViewGallery extends StatefulWidget {
|
||||||
this.customSize,
|
this.customSize,
|
||||||
this.allowImplicitScrolling = false,
|
this.allowImplicitScrolling = false,
|
||||||
this.enablePanAlways = false,
|
this.enablePanAlways = false,
|
||||||
}) : pageOptions = null,
|
}) : pageOptions = null;
|
||||||
assert(itemCount != null),
|
|
||||||
assert(builder != null);
|
|
||||||
|
|
||||||
/// A list of options to describe the items in the gallery
|
/// A list of options to describe the items in the gallery
|
||||||
final List<PhotoViewGalleryPageOptions>? pageOptions;
|
final List<PhotoViewGalleryPageOptions>? pageOptions;
|
||||||
|
|
@ -352,9 +350,9 @@ class _PhotoViewGalleryState extends State<PhotoViewGallery> {
|
||||||
/// The [maxScale], [minScale] and [initialScale] options may be [double] or a [PhotoViewComputedScale] constant
|
/// The [maxScale], [minScale] and [initialScale] options may be [double] or a [PhotoViewComputedScale] constant
|
||||||
///
|
///
|
||||||
class PhotoViewGalleryPageOptions {
|
class PhotoViewGalleryPageOptions {
|
||||||
PhotoViewGalleryPageOptions({
|
const PhotoViewGalleryPageOptions({
|
||||||
this.key,
|
this.key,
|
||||||
required this.imageProvider,
|
required ImageProvider this.imageProvider,
|
||||||
this.heroAttributes,
|
this.heroAttributes,
|
||||||
this.semanticLabel,
|
this.semanticLabel,
|
||||||
this.minScale,
|
this.minScale,
|
||||||
|
|
@ -379,8 +377,7 @@ class PhotoViewGalleryPageOptions {
|
||||||
this.disableGestures,
|
this.disableGestures,
|
||||||
this.errorBuilder,
|
this.errorBuilder,
|
||||||
}) : child = null,
|
}) : child = null,
|
||||||
childSize = null,
|
childSize = null;
|
||||||
assert(imageProvider != null);
|
|
||||||
|
|
||||||
const PhotoViewGalleryPageOptions.customChild({
|
const PhotoViewGalleryPageOptions.customChild({
|
||||||
this.key,
|
this.key,
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,6 @@ class PhotoViewGestureRecognizer extends ScaleGestureRecognizer {
|
||||||
super.debugOwner,
|
super.debugOwner,
|
||||||
this.validateAxis,
|
this.validateAxis,
|
||||||
this.touchSlopFactor = 1,
|
this.touchSlopFactor = 1,
|
||||||
PointerDeviceKind? kind,
|
|
||||||
this.disableScaleGestures = false,
|
this.disableScaleGestures = false,
|
||||||
}) : super(supportedDevices: null);
|
}) : super(supportedDevices: null);
|
||||||
final HitCornersDetector? hitDetector;
|
final HitCornersDetector? hitDetector;
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,10 @@ class ScaleBoundaries {
|
||||||
double get minScale {
|
double get minScale {
|
||||||
assert(_minScale is double || _minScale is PhotoViewComputedScale);
|
assert(_minScale is double || _minScale is PhotoViewComputedScale);
|
||||||
if (_minScale == PhotoViewComputedScale.contained) {
|
if (_minScale == PhotoViewComputedScale.contained) {
|
||||||
return _scaleForContained(outerSize, childSize) *
|
return _scaleForContained(outerSize, childSize) * (_minScale as PhotoViewComputedScale).multiplier;
|
||||||
(_minScale as PhotoViewComputedScale).multiplier; // ignore: avoid_as
|
|
||||||
}
|
}
|
||||||
if (_minScale == PhotoViewComputedScale.covered) {
|
if (_minScale == PhotoViewComputedScale.covered) {
|
||||||
return _scaleForCovering(outerSize, childSize) *
|
return _scaleForCovering(outerSize, childSize) * (_minScale as PhotoViewComputedScale).multiplier;
|
||||||
(_minScale as PhotoViewComputedScale).multiplier; // ignore: avoid_as
|
|
||||||
}
|
}
|
||||||
assert(_minScale >= 0.0);
|
assert(_minScale >= 0.0);
|
||||||
return _minScale;
|
return _minScale;
|
||||||
|
|
@ -46,16 +44,16 @@ class ScaleBoundaries {
|
||||||
double get maxScale {
|
double get maxScale {
|
||||||
assert(_maxScale is double || _maxScale is PhotoViewComputedScale);
|
assert(_maxScale is double || _maxScale is PhotoViewComputedScale);
|
||||||
if (_maxScale == PhotoViewComputedScale.contained) {
|
if (_maxScale == PhotoViewComputedScale.contained) {
|
||||||
return (_scaleForContained(outerSize, childSize) *
|
return (_scaleForContained(outerSize, childSize) * (_maxScale as PhotoViewComputedScale).multiplier).clamp(
|
||||||
(_maxScale as PhotoViewComputedScale) // ignore: avoid_as
|
minScale,
|
||||||
.multiplier)
|
double.infinity,
|
||||||
.clamp(minScale, double.infinity);
|
);
|
||||||
}
|
}
|
||||||
if (_maxScale == PhotoViewComputedScale.covered) {
|
if (_maxScale == PhotoViewComputedScale.covered) {
|
||||||
return (_scaleForCovering(outerSize, childSize) *
|
return (_scaleForCovering(outerSize, childSize) * (_maxScale as PhotoViewComputedScale).multiplier).clamp(
|
||||||
(_maxScale as PhotoViewComputedScale) // ignore: avoid_as
|
minScale,
|
||||||
.multiplier)
|
double.infinity,
|
||||||
.clamp(minScale, double.infinity);
|
);
|
||||||
}
|
}
|
||||||
return _maxScale.clamp(minScale, double.infinity);
|
return _maxScale.clamp(minScale, double.infinity);
|
||||||
}
|
}
|
||||||
|
|
@ -63,14 +61,10 @@ class ScaleBoundaries {
|
||||||
double get initialScale {
|
double get initialScale {
|
||||||
assert(_initialScale is double || _initialScale is PhotoViewComputedScale);
|
assert(_initialScale is double || _initialScale is PhotoViewComputedScale);
|
||||||
if (_initialScale == PhotoViewComputedScale.contained) {
|
if (_initialScale == PhotoViewComputedScale.contained) {
|
||||||
return _scaleForContained(outerSize, childSize) *
|
return _scaleForContained(outerSize, childSize) * (_initialScale as PhotoViewComputedScale).multiplier;
|
||||||
(_initialScale as PhotoViewComputedScale) // ignore: avoid_as
|
|
||||||
.multiplier;
|
|
||||||
}
|
}
|
||||||
if (_initialScale == PhotoViewComputedScale.covered) {
|
if (_initialScale == PhotoViewComputedScale.covered) {
|
||||||
return _scaleForCovering(outerSize, childSize) *
|
return _scaleForCovering(outerSize, childSize) * (_initialScale as PhotoViewComputedScale).multiplier;
|
||||||
(_initialScale as PhotoViewComputedScale) // ignore: avoid_as
|
|
||||||
.multiplier;
|
|
||||||
}
|
}
|
||||||
return _initialScale.clamp(minScale, maxScale);
|
return _initialScale.clamp(minScale, maxScale);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// dart format width=80
|
// dart format width=80
|
||||||
// ignore_for_file: unused_local_variable, unused_import
|
// ignore_for_file: unused_import
|
||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
import 'package:drift_dev/api/migrations_native.dart';
|
import 'package:drift_dev/api/migrations_native.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@ class LocalAlbumFactory {
|
||||||
String? linkedRemoteAlbumId,
|
String? linkedRemoteAlbumId,
|
||||||
int? assetCount,
|
int? assetCount,
|
||||||
}) {
|
}) {
|
||||||
id = TestUtils.uuid(id);
|
final albumId = TestUtils.uuid(id);
|
||||||
return LocalAlbum(
|
return LocalAlbum(
|
||||||
id: id,
|
id: albumId,
|
||||||
name: name ?? 'local_album_$id',
|
name: name ?? 'local_album_$albumId',
|
||||||
updatedAt: TestUtils.date(updatedAt),
|
updatedAt: TestUtils.date(updatedAt),
|
||||||
backupSelection: backupSelection ?? .none,
|
backupSelection: backupSelection ?? .none,
|
||||||
isIosSharedAlbum: isIosSharedAlbum ?? false,
|
isIosSharedAlbum: isIosSharedAlbum ?? false,
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ class LocalAssetFactory {
|
||||||
const LocalAssetFactory();
|
const LocalAssetFactory();
|
||||||
|
|
||||||
static LocalAsset create({String? id, String? name, String? remoteId}) {
|
static LocalAsset create({String? id, String? name, String? remoteId}) {
|
||||||
id = TestUtils.uuid(id);
|
final assetId = TestUtils.uuid(id);
|
||||||
|
|
||||||
return LocalAsset(
|
return LocalAsset(
|
||||||
id: id,
|
id: assetId,
|
||||||
name: name ?? 'local_$id.jpg',
|
name: name ?? 'local_$assetId.jpg',
|
||||||
remoteId: remoteId,
|
remoteId: remoteId,
|
||||||
type: AssetType.image,
|
type: AssetType.image,
|
||||||
createdAt: TestUtils.yesterday(),
|
createdAt: TestUtils.yesterday(),
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ class PartnerFactory {
|
||||||
const PartnerFactory();
|
const PartnerFactory();
|
||||||
|
|
||||||
static Partner create({String? id, String? email, String? name, bool? inTimeline}) {
|
static Partner create({String? id, String? email, String? name, bool? inTimeline}) {
|
||||||
id = TestUtils.uuid(id);
|
final partnerId = TestUtils.uuid(id);
|
||||||
return Partner(
|
return Partner(
|
||||||
id: id,
|
id: partnerId,
|
||||||
email: email ?? '$id@test.com',
|
email: email ?? '$partnerId@test.com',
|
||||||
name: name ?? 'user_$id',
|
name: name ?? 'user_$partnerId',
|
||||||
inTimeline: inTimeline ?? false,
|
inTimeline: inTimeline ?? false,
|
||||||
hasProfileImage: false,
|
hasProfileImage: false,
|
||||||
profileChangedAt: DateTime.now(),
|
profileChangedAt: DateTime.now(),
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ class RemoteAlbumFactory {
|
||||||
String? ownerName,
|
String? ownerName,
|
||||||
bool isShared = false,
|
bool isShared = false,
|
||||||
}) {
|
}) {
|
||||||
id = TestUtils.uuid(id);
|
final albumId = TestUtils.uuid(id);
|
||||||
return RemoteAlbum(
|
return RemoteAlbum(
|
||||||
id: id,
|
id: albumId,
|
||||||
name: name ?? 'remote_album_$id',
|
name: name ?? 'remote_album_$albumId',
|
||||||
ownerId: TestUtils.uuid(ownerId),
|
ownerId: TestUtils.uuid(ownerId),
|
||||||
description: description ?? '',
|
description: description ?? '',
|
||||||
createdAt: TestUtils.date(createdAt),
|
createdAt: TestUtils.date(createdAt),
|
||||||
|
|
@ -31,7 +31,7 @@ class RemoteAlbumFactory {
|
||||||
isActivityEnabled: isActivityEnabled,
|
isActivityEnabled: isActivityEnabled,
|
||||||
order: order,
|
order: order,
|
||||||
assetCount: assetCount,
|
assetCount: assetCount,
|
||||||
ownerName: ownerName ?? 'owner_$id',
|
ownerName: ownerName ?? 'owner_$albumId',
|
||||||
isShared: isShared,
|
isShared: isShared,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@ class RemoteAssetFactory {
|
||||||
DateTime? deletedAt,
|
DateTime? deletedAt,
|
||||||
String? localId,
|
String? localId,
|
||||||
}) {
|
}) {
|
||||||
id = TestUtils.uuid(id);
|
final assetId = TestUtils.uuid(id);
|
||||||
|
|
||||||
return RemoteAsset(
|
return RemoteAsset(
|
||||||
id: id,
|
id: assetId,
|
||||||
name: name ?? 'remote_$id.jpg',
|
name: name ?? 'remote_$assetId.jpg',
|
||||||
ownerId: TestUtils.uuid(ownerId),
|
ownerId: TestUtils.uuid(ownerId),
|
||||||
checksum: 'checksum-$id',
|
checksum: 'checksum-$assetId',
|
||||||
type: type,
|
type: type,
|
||||||
createdAt: TestUtils.yesterday(),
|
createdAt: TestUtils.yesterday(),
|
||||||
updatedAt: TestUtils.now(),
|
updatedAt: TestUtils.now(),
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ class UserFactory {
|
||||||
bool? hasProfileImage,
|
bool? hasProfileImage,
|
||||||
AvatarColor? avatarColor,
|
AvatarColor? avatarColor,
|
||||||
}) {
|
}) {
|
||||||
id = TestUtils.uuid(id);
|
final userId = TestUtils.uuid(id);
|
||||||
return User(
|
return User(
|
||||||
id: id,
|
id: userId,
|
||||||
name: name ?? 'user_$id',
|
name: name ?? 'user_$userId',
|
||||||
email: email ?? '$id@test.com',
|
email: email ?? '$userId@test.com',
|
||||||
profileChangedAt: TestUtils.date(profileChangedAt),
|
profileChangedAt: TestUtils.date(profileChangedAt),
|
||||||
hasProfileImage: hasProfileImage ?? false,
|
hasProfileImage: hasProfileImage ?? false,
|
||||||
avatarColor: avatarColor ?? .primary,
|
avatarColor: avatarColor ?? .primary,
|
||||||
|
|
@ -32,11 +32,11 @@ class UserFactory {
|
||||||
bool? hasProfileImage,
|
bool? hasProfileImage,
|
||||||
AvatarColor? avatarColor,
|
AvatarColor? avatarColor,
|
||||||
}) {
|
}) {
|
||||||
id = TestUtils.uuid(id);
|
final userId = TestUtils.uuid(id);
|
||||||
return UserDto(
|
return UserDto(
|
||||||
id: id,
|
id: userId,
|
||||||
name: name ?? 'user_$id',
|
name: name ?? 'user_$userId',
|
||||||
email: email ?? '$id@test.com',
|
email: email ?? '$userId@test.com',
|
||||||
profileChangedAt: TestUtils.date(profileChangedAt),
|
profileChangedAt: TestUtils.date(profileChangedAt),
|
||||||
hasProfileImage: hasProfileImage ?? false,
|
hasProfileImage: hasProfileImage ?? false,
|
||||||
avatarColor: avatarColor ?? .primary,
|
avatarColor: avatarColor ?? .primary,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue