1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-29 15:11:58 +00:00

chore(mobile): Add const linter (#14447)

This commit is contained in:
Alex 2024-12-02 09:33:44 -06:00 committed by GitHub
parent 4eb7758f56
commit 1bb6926b5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 39 additions and 34 deletions

View file

@ -28,6 +28,7 @@ linter:
use_build_context_synchronously: false use_build_context_synchronously: false
require_trailing_commas: true require_trailing_commas: true
unrelated_type_equality_checks: true unrelated_type_equality_checks: true
prefer_const_constructors: 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

View file

@ -78,7 +78,7 @@ class AlbumsPage extends HookConsumerWidget {
showUploadButton: false, showUploadButton: false,
actions: [ actions: [
IconButton( IconButton(
icon: Icon( icon: const Icon(
Icons.add_rounded, Icons.add_rounded,
size: 28, size: 28,
), ),
@ -112,13 +112,13 @@ class AlbumsPage extends HookConsumerWidget {
], ],
begin: Alignment.topLeft, begin: Alignment.topLeft,
end: Alignment.bottomRight, end: Alignment.bottomRight,
transform: GradientRotation(0.5 * pi), transform: const GradientRotation(0.5 * pi),
), ),
), ),
child: TextField( child: TextField(
autofocus: false, autofocus: false,
decoration: InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.all(16), contentPadding: const EdgeInsets.all(16),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(25), borderRadius: BorderRadius.circular(25),
borderSide: BorderSide( borderSide: BorderSide(
@ -362,13 +362,13 @@ class SortButton extends ConsumerWidget {
return MenuAnchor( return MenuAnchor(
style: MenuStyle( style: MenuStyle(
elevation: WidgetStatePropertyAll(1), elevation: const WidgetStatePropertyAll(1),
shape: WidgetStateProperty.all( shape: WidgetStateProperty.all(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24), borderRadius: BorderRadius.circular(24),
), ),
), ),
padding: WidgetStatePropertyAll( padding: const WidgetStatePropertyAll(
EdgeInsets.all(4), EdgeInsets.all(4),
), ),
), ),

View file

@ -49,7 +49,7 @@ class AlbumOptionsPage extends HookConsumerWidget {
if (isSuccess) { if (isSuccess) {
context.navigateTo( context.navigateTo(
TabControllerRoute(children: [AlbumsRoute()]), const TabControllerRoute(children: [AlbumsRoute()]),
); );
} else { } else {
showErrorMessage(); showErrorMessage();

View file

@ -33,7 +33,7 @@ class AlbumSharedUserSelectionPage extends HookConsumerWidget {
if (newAlbum != null) { if (newAlbum != null) {
ref.watch(albumTitleProvider.notifier).clearAlbumTitle(); ref.watch(albumTitleProvider.notifier).clearAlbumTitle();
context.maybePop(true); context.maybePop(true);
context.navigateTo(TabControllerRoute(children: [AlbumsRoute()])); context.navigateTo(const TabControllerRoute(children: [AlbumsRoute()]));
} }
ScaffoldMessenger( ScaffoldMessenger(

View file

@ -28,7 +28,7 @@ class LibraryPage extends ConsumerWidget {
ref.watch(serverInfoProvider.select((v) => v.serverFeatures.trash)); ref.watch(serverInfoProvider.select((v) => v.serverFeatures.trash));
return Scaffold( return Scaffold(
appBar: ImmichAppBar(), appBar: const ImmichAppBar(),
body: Padding( body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
child: ListView( child: ListView(
@ -81,7 +81,7 @@ class LibraryPage extends ConsumerWidget {
], ],
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
QuickAccessButtons(), const QuickAccessButtons(),
const SizedBox( const SizedBox(
height: 32, height: 32,
), ),
@ -122,8 +122,8 @@ class QuickAccessButtons extends ConsumerWidget {
ListTile( ListTile(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topLeft: Radius.circular(20), topLeft: const Radius.circular(20),
topRight: Radius.circular(20), topRight: const Radius.circular(20),
bottomLeft: Radius.circular(partners.isEmpty ? 20 : 0), bottomLeft: Radius.circular(partners.isEmpty ? 20 : 0),
bottomRight: Radius.circular(partners.isEmpty ? 20 : 0), bottomRight: Radius.circular(partners.isEmpty ? 20 : 0),
), ),
@ -173,7 +173,7 @@ class PartnerList extends ConsumerWidget {
right: 18.0, right: 18.0,
), ),
leading: userAvatar(context, partner, radius: 16), leading: userAvatar(context, partner, radius: 16),
title: Text( title: const Text(
"partner_list_user_photos", "partner_list_user_photos",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,

View file

@ -60,7 +60,7 @@ class PlacesCollectionPage extends HookConsumerWidget {
); );
}, },
error: (error, stask) => const Text('Error getting places'), error: (error, stask) => const Text('Error getting places'),
loading: () => Center(child: const CircularProgressIndicator()), loading: () => const Center(child: CircularProgressIndicator()),
), ),
], ],
), ),

View file

@ -499,8 +499,8 @@ class SearchPage extends HookConsumerWidget {
controller: textSearchController, controller: textSearchController,
decoration: InputDecoration( decoration: InputDecoration(
contentPadding: prefilter != null contentPadding: prefilter != null
? EdgeInsets.only(left: 24) ? const EdgeInsets.only(left: 24)
: EdgeInsets.all(8), : const EdgeInsets.all(8),
prefixIcon: prefilter != null prefixIcon: prefilter != null
? null ? null
: Icon( : Icon(
@ -647,7 +647,9 @@ class SearchResultGrid extends StatelessWidget {
stackEnabled: false, stackEnabled: false,
emptyIndicator: Padding( emptyIndicator: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0), padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: !isSearching ? SearchEmptyContent() : SizedBox.shrink(), child: !isSearching
? const SearchEmptyContent()
: const SizedBox.shrink(),
), ),
), ),
), ),
@ -666,7 +668,7 @@ class SearchEmptyContent extends StatelessWidget {
child: ListView( child: ListView(
shrinkWrap: false, shrinkWrap: false,
children: [ children: [
SizedBox(height: 40), const SizedBox(height: 40),
Center( Center(
child: Image.asset( child: Image.asset(
context.isDarkTheme context.isDarkTheme
@ -675,15 +677,15 @@ class SearchEmptyContent extends StatelessWidget {
height: 125, height: 125,
), ),
), ),
SizedBox(height: 16), const SizedBox(height: 16),
Center( Center(
child: Text( child: Text(
"Search for your photos and videos", "Search for your photos and videos",
style: context.textTheme.labelLarge, style: context.textTheme.labelLarge,
), ),
), ),
SizedBox(height: 32), const SizedBox(height: 32),
QuickLinkList(), const QuickLinkList(),
], ],
), ),
); );
@ -725,13 +727,13 @@ class QuickLinkList extends StatelessWidget {
QuickLink( QuickLink(
title: 'videos'.tr(), title: 'videos'.tr(),
icon: Icons.play_circle_outline_rounded, icon: Icons.play_circle_outline_rounded,
onTap: () => context.pushRoute(AllVideosRoute()), onTap: () => context.pushRoute(const AllVideosRoute()),
), ),
QuickLink( QuickLink(
title: 'favorites'.tr(), title: 'favorites'.tr(),
icon: Icons.favorite_border_rounded, icon: Icons.favorite_border_rounded,
isBottom: true, isBottom: true,
onTap: () => context.pushRoute(FavoritesRoute()), onTap: () => context.pushRoute(const FavoritesRoute()),
), ),
], ],
), ),

View file

@ -39,7 +39,9 @@ class AuthApiRepository extends ApiRepository implements IAuthApiRepository {
@override @override
Future<void> logout() async { Future<void> logout() async {
await _apiService.authenticationApi.logout().timeout(Duration(seconds: 7)); await _apiService.authenticationApi
.logout()
.timeout(const Duration(seconds: 7));
} }
_mapLoginReponse(LoginResponseDto dto) { _mapLoginReponse(LoginResponseDto dto) {

View file

@ -104,7 +104,7 @@ class ApiService implements Authentication {
try { try {
await setEndpoint(serverUrl); await setEndpoint(serverUrl);
await serverInfoApi.pingServer().timeout(Duration(seconds: 5)); await serverInfoApi.pingServer().timeout(const Duration(seconds: 5));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
return false; return false;
} on SocketException catch (_) { } on SocketException catch (_) {

View file

@ -198,7 +198,7 @@ ThemeData getThemeData({
scrolledUnderElevation: 0, scrolledUnderElevation: 0,
centerTitle: true, centerTitle: true,
), ),
textTheme: TextTheme( textTheme: const TextTheme(
displayLarge: TextStyle( displayLarge: TextStyle(
fontSize: 26, fontSize: 26,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -211,15 +211,15 @@ ThemeData getThemeData({
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
titleSmall: const TextStyle( titleSmall: TextStyle(
fontSize: 16.0, fontSize: 16.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
titleMedium: const TextStyle( titleMedium: TextStyle(
fontSize: 18.0, fontSize: 18.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
titleLarge: const TextStyle( titleLarge: TextStyle(
fontSize: 26.0, fontSize: 26.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),

View file

@ -46,7 +46,7 @@ class AlbumViewerAppbar extends HookConsumerWidget
final bool success; final bool success;
if (album.shared) { if (album.shared) {
success = await ref.watch(albumProvider.notifier).deleteAlbum(album); success = await ref.watch(albumProvider.notifier).deleteAlbum(album);
context.navigateTo(TabControllerRoute(children: [AlbumsRoute()])); context.navigateTo(const TabControllerRoute(children: [AlbumsRoute()]));
} else { } else {
success = await ref.watch(albumProvider.notifier).deleteAlbum(album); success = await ref.watch(albumProvider.notifier).deleteAlbum(album);
context context
@ -113,7 +113,7 @@ class AlbumViewerAppbar extends HookConsumerWidget
await ref.watch(albumProvider.notifier).leaveAlbum(album); await ref.watch(albumProvider.notifier).leaveAlbum(album);
if (isSuccess) { if (isSuccess) {
context.navigateTo(TabControllerRoute(children: [AlbumsRoute()])); context.navigateTo(const TabControllerRoute(children: [AlbumsRoute()]));
} else { } else {
context.pop(); context.pop();
ImmichToast.show( ImmichToast.show(

View file

@ -338,7 +338,7 @@ class BottomGalleryBar extends ConsumerWidget {
), ),
position: DecorationPosition.background, position: DecorationPosition.background,
child: Padding( child: Padding(
padding: EdgeInsets.only(top: 40.0), padding: const EdgeInsets.only(top: 40.0),
child: Column( child: Column(
children: [ children: [
if (showVideoPlayerControls) const VideoControls(), if (showVideoPlayerControls) const VideoControls(),

View file

@ -143,9 +143,9 @@ class ImmichAppBarDialog extends HookConsumerWidget {
); );
}, },
trailing: isLoggingOut.value trailing: isLoggingOut.value
? SizedBox.square( ? const SizedBox.square(
dimension: 20, dimension: 20,
child: const CircularProgressIndicator(strokeWidth: 2), child: CircularProgressIndicator(strokeWidth: 2),
) )
: null, : null,
); );

View file

@ -27,7 +27,7 @@ void main() {
mapStateNotifier = MockMapStateNotifier(mapState); mapStateNotifier = MockMapStateNotifier(mapState);
overrides = [ overrides = [
mapStateNotifierProvider.overrideWith(() => mapStateNotifier), mapStateNotifierProvider.overrideWith(() => mapStateNotifier),
localeProvider.overrideWithValue(Locale("en")), localeProvider.overrideWithValue(const Locale("en")),
]; ];
}); });