1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-28 06:31: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
require_trailing_commas: true
unrelated_type_equality_checks: true
prefer_const_constructors: true
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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