Merge pull request #378 from ente-io/pref_const_constructor

lint: enable prefer_const_constructors_in_immutables rule
This commit is contained in:
Manav 2022-07-04 14:54:27 +05:30 committed by GitHub
commit f87de99b01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 65 additions and 65 deletions

View file

@ -50,12 +50,12 @@ analyzer:
constant_identifier_names: warning
prefer_const_constructors: warning
prefer_const_declarations: warning
prefer_const_constructors_in_immutables: warning
unnecessary_const: error
cancel_subscriptions: error
use_build_context_synchronously: ignore # experimental lint, requires many changes
prefer_interpolation_to_compose_strings: ignore # later too many warnings
prefer_const_constructors_in_immutables: ignore # too many warnings
prefer_double_quotes: ignore # too many warnings
avoid_renaming_method_parameters: ignore # incorrect warnings for `equals` overrides

View file

@ -20,7 +20,7 @@ class EnteApp extends StatefulWidget {
final Future<void> Function(String) runBackgroundTask;
final Future<void> Function(String) killBackgroundTask;
EnteApp(
const EnteApp(
this.runBackgroundTask,
this.killBackgroundTask, {
Key key,

View file

@ -60,8 +60,8 @@ Future<void> _runInForeground() async {
_scheduleFGSync('appStart in FG');
runApp(
AppLock(
builder: (args) => EnteApp(_runBackgroundTask, _killBGTask),
lockScreen: LockScreen(),
builder: (args) => const EnteApp(_runBackgroundTask, _killBGTask),
lockScreen: const LockScreen(),
enabled: Configuration.instance.shouldShowLockScreen(),
lightTheme: lightThemeData,
darkTheme: darkThemeData,

View file

@ -230,9 +230,9 @@ class UserService {
} else {
await _saveConfiguration(response);
if (Configuration.instance.getEncryptedToken() != null) {
page = PasswordReentryPage();
page = const PasswordReentryPage();
} else {
page = PasswordEntryPage();
page = const PasswordEntryPage();
}
}
Navigator.of(context).pushAndRemoveUntil(
@ -418,7 +418,7 @@ class UserService {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
return PasswordReentryPage();
return const PasswordReentryPage();
},
),
(route) => route.isFirst,
@ -432,7 +432,7 @@ class UserService {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
return LoginPage();
return const LoginPage();
},
),
(route) => route.isFirst,
@ -486,7 +486,7 @@ class UserService {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
return LoginPage();
return const LoginPage();
},
),
(route) => route.isFirst,
@ -551,7 +551,7 @@ class UserService {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
return PasswordReentryPage();
return const PasswordReentryPage();
},
),
(route) => route.isFirst,
@ -564,7 +564,7 @@ class UserService {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
return LoginPage();
return const LoginPage();
},
),
(route) => route.isFirst,

View file

@ -17,7 +17,7 @@ import 'package:photos/utils/data_util.dart';
import 'package:step_progress_indicator/step_progress_indicator.dart';
class EmailEntryPage extends StatefulWidget {
EmailEntryPage({Key key}) : super(key: key);
const EmailEntryPage({Key key}) : super(key: key);
@override
State<EmailEntryPage> createState() => _EmailEntryPageState();

View file

@ -7,7 +7,7 @@ import 'package:photos/ui/common/dynamic_fab.dart';
import 'package:photos/ui/common/web_page.dart';
class LoginPage extends StatefulWidget {
LoginPage({Key key}) : super(key: key);
const LoginPage({Key key}) : super(key: key);
@override
State<LoginPage> createState() => _LoginPageState();

View file

@ -9,7 +9,7 @@ class OTTVerificationPage extends StatefulWidget {
final bool isChangeEmail;
final bool isCreateAccountScreen;
OTTVerificationPage(
const OTTVerificationPage(
this.email, {
this.isChangeEmail = false,
this.isCreateAccountScreen = false,

View file

@ -24,7 +24,7 @@ enum PasswordEntryMode {
class PasswordEntryPage extends StatefulWidget {
final PasswordEntryMode mode;
PasswordEntryPage({this.mode = PasswordEntryMode.set, Key key})
const PasswordEntryPage({this.mode = PasswordEntryMode.set, Key key})
: super(key: key);
@override

View file

@ -9,7 +9,7 @@ import 'package:photos/ui/home_widget.dart';
import 'package:photos/utils/dialog_util.dart';
class PasswordReentryPage extends StatefulWidget {
PasswordReentryPage({Key key}) : super(key: key);
const PasswordReentryPage({Key key}) : super(key: key);
@override
State<PasswordReentryPage> createState() => _PasswordReentryPageState();

View file

@ -57,7 +57,7 @@ class _RecoveryPageState extends State<RecoveryPage> {
builder: (BuildContext context) {
return WillPopScope(
onWillPop: () async => false,
child: PasswordEntryPage(
child: const PasswordEntryPage(
mode: PasswordEntryMode.reset,
),
);

View file

@ -10,7 +10,7 @@ import 'package:photos/utils/dialog_util.dart';
import 'package:photos/utils/toast_util.dart';
class SessionsPage extends StatefulWidget {
SessionsPage({Key key}) : super(key: key);
const SessionsPage({Key key}) : super(key: key);
@override
State<SessionsPage> createState() => _SessionsPageState();

View file

@ -9,7 +9,7 @@ class TwoFactorRecoveryPage extends StatefulWidget {
final String encryptedSecret;
final String secretDecryptionNonce;
TwoFactorRecoveryPage(
const TwoFactorRecoveryPage(
this.sessionID,
this.encryptedSecret,
this.secretDecryptionNonce, {

View file

@ -15,7 +15,8 @@ class TwoFactorSetupPage extends StatefulWidget {
final String secretCode;
final String qrCode;
TwoFactorSetupPage(this.secretCode, this.qrCode, {Key key}) : super(key: key);
const TwoFactorSetupPage(this.secretCode, this.qrCode, {Key key})
: super(key: key);
@override
State<TwoFactorSetupPage> createState() => _TwoFactorSetupPageState();

View file

@ -9,7 +9,7 @@ class DynamicFAB extends StatelessWidget {
final String buttonText;
final Function onPressedFunction;
DynamicFAB({
const DynamicFAB({
Key key,
this.isKeypadOpen,
this.buttonText,

View file

@ -11,7 +11,7 @@ class GradientButton extends StatelessWidget {
// padding between the text and icon
final double paddingValue;
GradientButton({
const GradientButton({
Key key,
this.child,
this.linearGradientColors = const [

View file

@ -18,7 +18,7 @@ class DraggableScrollbar extends StatefulWidget {
final String Function(int) labelTextBuilder;
final bool isEnabled;
DraggableScrollbar({
const DraggableScrollbar({
Key key,
@required this.child,
this.backgroundColor = Colors.white,

View file

@ -54,7 +54,7 @@ class HugeListView<T> extends StatefulWidget {
final bool isDraggableScrollbarEnabled;
HugeListView({
const HugeListView({
Key key,
this.controller,
@required this.startIndex,

View file

@ -145,15 +145,15 @@ class _LandingPageWidgetState extends State<LandingPageWidget> {
void _navigateToSignUpPage() {
Widget page;
if (Configuration.instance.getEncryptedToken() == null) {
page = EmailEntryPage();
page = const EmailEntryPage();
} else {
// No key
if (Configuration.instance.getKeyAttributes() == null) {
// Never had a key
page = PasswordEntryPage();
page = const PasswordEntryPage();
} else if (Configuration.instance.getKey() == null) {
// Yet to decrypt the key
page = PasswordReentryPage();
page = const PasswordReentryPage();
} else {
// All is well, user just has not subscribed
page = getSubscriptionPage(isOnBoarding: true);
@ -171,15 +171,15 @@ class _LandingPageWidgetState extends State<LandingPageWidget> {
void _navigateToSignInPage() {
Widget page;
if (Configuration.instance.getEncryptedToken() == null) {
page = LoginPage();
page = const LoginPage();
} else {
// No key
if (Configuration.instance.getKeyAttributes() == null) {
// Never had a key
page = PasswordEntryPage();
page = const PasswordEntryPage();
} else if (Configuration.instance.getKey() == null) {
// Yet to decrypt the key
page = PasswordReentryPage();
page = const PasswordReentryPage();
} else {
// All is well, user just has not subscribed
page = getSubscriptionPage(isOnBoarding: true);

View file

@ -197,7 +197,7 @@ class FullScreenMemory extends StatefulWidget {
final List<Memory> memories;
final int index;
FullScreenMemory(this.title, this.memories, this.index, {Key key})
const FullScreenMemory(this.title, this.memories, this.index, {Key key})
: super(key: key);
@override

View file

@ -74,12 +74,13 @@ class _GNavState extends State<GNav> {
@override
Widget build(BuildContext context) {
debugPrint(
'${(_GNavState).toString()} - build with index ${widget.selectedIndex}',
);
selectedIndex = widget.selectedIndex;
return Container(
color: widget.backgroundColor ?? Colors.transparent,
// padding: EdgeInsets.all(12),
// alignment: Alignment.center,
child: Row(
mainAxisAlignment: widget.mainAxisAlignment,
children: widget.tabs
@ -300,7 +301,6 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
void initState() {
super.initState();
_expanded = widget.active;
expandController =
AnimationController(vsync: this, duration: widget.duration)
..addListener(() => setState(() {}));
@ -309,7 +309,6 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
@override
void dispose() {
expandController.dispose();
super.dispose();
}

View file

@ -16,7 +16,7 @@ import 'package:photos/utils/navigation_util.dart';
import 'package:photos/utils/toast_util.dart';
class AccountSectionWidget extends StatefulWidget {
AccountSectionWidget({Key key}) : super(key: key);
const AccountSectionWidget({Key key}) : super(key: key);
@override
AccountSectionWidgetState createState() => AccountSectionWidgetState();
@ -114,7 +114,7 @@ class AccountSectionWidgetState extends State<AccountSectionWidget> {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
return PasswordEntryPage(
return const PasswordEntryPage(
mode: PasswordEntryMode.update,
);
},

View file

@ -8,7 +8,7 @@ import 'package:photos/services/update_service.dart';
class AppUpdateDialog extends StatefulWidget {
final LatestVersionInfo latestVersionInfo;
AppUpdateDialog(this.latestVersionInfo, {Key key}) : super(key: key);
const AppUpdateDialog(this.latestVersionInfo, {Key key}) : super(key: key);
@override
State<AppUpdateDialog> createState() => _AppUpdateDialogState();
@ -95,7 +95,7 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
class ApkDownloaderDialog extends StatefulWidget {
final LatestVersionInfo versionInfo;
ApkDownloaderDialog(this.versionInfo, {Key key}) : super(key: key);
const ApkDownloaderDialog(this.versionInfo, {Key key}) : super(key: key);
@override
State<ApkDownloaderDialog> createState() => _ApkDownloaderDialogState();

View file

@ -21,7 +21,7 @@ import 'package:photos/utils/toast_util.dart';
import 'package:url_launcher/url_launcher.dart';
class BackupSectionWidget extends StatefulWidget {
BackupSectionWidget({Key key}) : super(key: key);
const BackupSectionWidget({Key key}) : super(key: key);
@override
BackupSectionWidgetState createState() => BackupSectionWidgetState();

View file

@ -8,7 +8,7 @@ import 'package:photos/ui/settings/settings_text_item.dart';
import 'package:url_launcher/url_launcher.dart';
class DangerSectionWidget extends StatefulWidget {
DangerSectionWidget({Key key}) : super(key: key);
const DangerSectionWidget({Key key}) : super(key: key);
@override
State<DangerSectionWidget> createState() => _DangerSectionWidgetState();

View file

@ -12,7 +12,7 @@ import 'package:photos/ui/payment/subscription.dart';
import 'package:photos/utils/data_util.dart';
class DetailsSectionWidget extends StatefulWidget {
DetailsSectionWidget({Key key}) : super(key: key);
const DetailsSectionWidget({Key key}) : super(key: key);
@override
State<DetailsSectionWidget> createState() => _DetailsSectionWidgetState();

View file

@ -19,7 +19,7 @@ import 'package:photos/utils/auth_util.dart';
import 'package:photos/utils/toast_util.dart';
class SecuritySectionWidget extends StatefulWidget {
SecuritySectionWidget({Key key}) : super(key: key);
const SecuritySectionWidget({Key key}) : super(key: key);
@override
State<SecuritySectionWidget> createState() => _SecuritySectionWidgetState();
@ -261,7 +261,7 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
return SessionsPage();
return const SessionsPage();
},
),
);

View file

@ -67,16 +67,16 @@ class SettingsPage extends StatelessWidget {
contents.add(const Padding(padding: EdgeInsets.all(4)));
if (hasLoggedIn) {
contents.addAll([
DetailsSectionWidget(),
const DetailsSectionWidget(),
const Padding(padding: EdgeInsets.only(bottom: 24)),
BackupSectionWidget(),
const BackupSectionWidget(),
sectionDivider,
AccountSectionWidget(),
const AccountSectionWidget(),
sectionDivider,
]);
}
contents.addAll([
SecuritySectionWidget(),
const SecuritySectionWidget(),
sectionDivider,
const SupportSectionWidget(),
sectionDivider,
@ -87,7 +87,7 @@ class SettingsPage extends StatelessWidget {
if (hasLoggedIn) {
contents.addAll([
sectionDivider,
DangerSectionWidget(),
const DangerSectionWidget(),
]);
}

View file

@ -17,7 +17,7 @@ import 'package:tuple/tuple.dart';
class ManageSharedLinkWidget extends StatefulWidget {
final Collection collection;
ManageSharedLinkWidget({Key key, this.collection}) : super(key: key);
const ManageSharedLinkWidget({Key key, this.collection}) : super(key: key);
@override
State<ManageSharedLinkWidget> createState() => _ManageSharedLinkWidgetState();

View file

@ -29,7 +29,7 @@ import 'package:photos/utils/toast_util.dart';
class SharingDialog extends StatefulWidget {
final Collection collection;
SharingDialog(this.collection, {Key key}) : super(key: key);
const SharingDialog(this.collection, {Key key}) : super(key: key);
@override
State<SharingDialog> createState() => _SharingDialogState();

View file

@ -18,7 +18,7 @@ import 'package:photos/utils/toast_util.dart';
class DeduplicatePage extends StatefulWidget {
final List<DuplicateFiles> duplicates;
DeduplicatePage(this.duplicates, {Key key}) : super(key: key);
const DeduplicatePage(this.duplicates, {Key key}) : super(key: key);
@override
State<DeduplicatePage> createState() => _DeduplicatePageState();

View file

@ -9,7 +9,7 @@ import 'package:photos/utils/delete_file_util.dart';
class FreeSpacePage extends StatefulWidget {
final BackupStatus status;
FreeSpacePage(this.status, {Key key}) : super(key: key);
const FreeSpacePage(this.status, {Key key}) : super(key: key);
@override
State<FreeSpacePage> createState() => _FreeSpacePageState();

View file

@ -5,7 +5,7 @@ import 'package:photos/ui/tools/app_lock.dart';
import 'package:photos/utils/auth_util.dart';
class LockScreen extends StatefulWidget {
LockScreen({Key key}) : super(key: key);
const LockScreen({Key key}) : super(key: key);
@override
State<LockScreen> createState() => _LockScreenState();

View file

@ -53,7 +53,7 @@ class DetailPageConfiguration {
class DetailPage extends StatefulWidget {
final DetailPageConfiguration config;
DetailPage(this.config, {key}) : super(key: key);
const DetailPage(this.config, {key}) : super(key: key);
@override
State<DetailPage> createState() => _DetailPageState();

View file

@ -7,7 +7,7 @@ import 'package:photos/utils/exif_util.dart';
class ExifInfoDialog extends StatefulWidget {
final File file;
ExifInfoDialog(this.file, {Key key}) : super(key: key);
const ExifInfoDialog(this.file, {Key key}) : super(key: key);
@override
State<ExifInfoDialog> createState() => _ExifInfoDialogState();

View file

@ -31,7 +31,7 @@ class FadingAppBar extends StatefulWidget implements PreferredSizeWidget {
final bool shouldShowActions;
final int userID;
FadingAppBar(
const FadingAppBar(
this.file,
this.onFileDeleted,
this.userID,

View file

@ -20,7 +20,7 @@ class FadingBottomBar extends StatefulWidget {
final Function(File) onEditRequested;
final bool showOnlyInfoButton;
FadingBottomBar(
const FadingBottomBar(
this.file,
this.onEditRequested,
this.showOnlyInfoButton, {

View file

@ -19,7 +19,7 @@ class VideoWidget extends StatefulWidget {
final String tagPrefix;
final Function(bool) playbackCallback;
VideoWidget(
const VideoWidget(
this.file, {
this.autoPlay = false,
this.tagPrefix,

View file

@ -19,7 +19,7 @@ class ZoomableImage extends StatefulWidget {
final String tagPrefix;
final Decoration backgroundDecoration;
ZoomableImage(
const ZoomableImage(
this.photo, {
Key key,
this.shouldDisableScroll,

View file

@ -18,7 +18,7 @@ class ZoomableLiveImage extends StatefulWidget {
final String tagPrefix;
final Decoration backgroundDecoration;
ZoomableLiveImage(
const ZoomableLiveImage(
this.file, {
Key key,
this.shouldDisableScroll,

View file

@ -75,7 +75,7 @@ class DeviceFolderPage extends StatelessWidget {
class BackupConfigurationHeaderWidget extends StatefulWidget {
final String path;
BackupConfigurationHeaderWidget(this.path, {Key key}) : super(key: key);
const BackupConfigurationHeaderWidget(this.path, {Key key}) : super(key: key);
@override
State<BackupConfigurationHeaderWidget> createState() =>

View file

@ -37,7 +37,7 @@ class Gallery extends StatefulWidget {
final bool smallerTodayFont;
final String albumName;
Gallery({
const Gallery({
@required this.asyncLoader,
@required this.selectedFiles,
@required this.tagPrefix,

View file

@ -22,7 +22,7 @@ class GalleryAppBarWidget extends StatefulWidget {
final String path;
final Collection collection;
GalleryAppBarWidget(
const GalleryAppBarWidget(
this.type,
this.title,
this.selectedFiles, {

View file

@ -18,7 +18,7 @@ class LocationSearchResultsPage extends StatefulWidget {
final ViewPort viewPort;
final String name;
LocationSearchResultsPage(this.viewPort, this.name, {Key key})
const LocationSearchResultsPage(this.viewPort, this.name, {Key key})
: super(key: key);
@override