Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lints): use_key_in_widget_constructors rule #159

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ linter:

non_constant_identifier_names: false

use_key_in_widget_constructors: false

constant_identifier_names: false

prefer_typing_uninitialized_variables: false
6 changes: 4 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ Future<void> main() async {
// Init Hive
await locator<DatabaseService>().init();

runApp(CircuitVerseMobile());
runApp(const CircuitVerseMobile());
}

class CircuitVerseMobile extends StatelessWidget {
const CircuitVerseMobile({Key key}) : super(key: key);

// This widget is the root of CircuitVerse Mobile.
@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -77,7 +79,7 @@ class CircuitVerseMobile extends StatelessWidget {
debugShowCheckedModeBanner: false,
onGenerateRoute: CVRouter.generateRoute,
theme: ThemeProvider.themeOf(themeContext).data,
home: StartUpView(),
home: const StartUpView(),
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/components/cv_tab_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class CVTabBar extends StatelessWidget implements PreferredSizeWidget {
final Color color;
final TabBar tabBar;

const CVTabBar({this.color, this.tabBar});
const CVTabBar({Key key, this.color, this.tabBar}) : super(key: key);

@override
Size get preferredSize => tabBar.preferredSize;
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/views/about/about_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class AboutView extends StatefulWidget {
static const String id = 'about_view';

const AboutView({Key key}) : super(key: key);

@override
_AboutViewState createState() => _AboutViewState();
}
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/views/authentication/forgot_password_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import 'package:mobile_app/viewmodels/authentication/forgot_password_viewmodel.d

class ForgotPasswordView extends StatefulWidget {
static const String id = 'forgot_password_view';

const ForgotPasswordView({Key key}) : super(key: key);
@override
_ForgotPasswordViewState createState() => _ForgotPasswordViewState();
}
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/views/authentication/login_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import 'package:mobile_app/viewmodels/authentication/login_viewmodel.dart';
class LoginView extends StatefulWidget {
static const String id = 'login_view';

const LoginView({Key key}) : super(key: key);

@override
_LoginViewState createState() => _LoginViewState();
}
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/views/authentication/signup_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import 'package:mobile_app/viewmodels/authentication/signup_viewmodel.dart';
class SignupView extends StatefulWidget {
static const String id = 'signup_view';

const SignupView({Key key}) : super(key: key);

@override
_SignupViewState createState() => _SignupViewState();
}
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/views/base_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ class BaseView<T extends BaseModel> extends StatefulWidget {
final T model;

const BaseView({
Key key,
@required this.builder,
this.onModelReady,
this.onModelDestroy,
this.model,
});
}) : super(key: key);

@override
_BaseViewState<T> createState() => _BaseViewState<T>();
Expand Down
8 changes: 5 additions & 3 deletions lib/ui/views/cv_landing_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class CVLandingView extends StatefulWidget {
static const String id = 'cv_landing_view';

const CVLandingView({Key key}) : super(key: key);

@override
_CVLandingViewState createState() => _CVLandingViewState();
}
Expand All @@ -35,13 +37,13 @@ class _CVLandingViewState extends State<CVLandingView> {
int _selectedIndex = 0;

final List<Widget> _items = [
HomeView(),
const HomeView(),
const FeaturedProjectsView(showAppBar: false),
AboutView(),
const AboutView(),
const ContributorsView(showAppBar: false),
const TeachersView(showAppBar: false),
const ProfileView(),
MyGroupsView(),
const MyGroupsView(),
];

void setSelectedIndexTo(int index) {
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/views/groups/my_groups_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import 'package:mobile_app/viewmodels/groups/my_groups_viewmodel.dart';
class MyGroupsView extends StatefulWidget {
static const String id = 'my_groups_view';

const MyGroupsView({Key key}) : super(key: key);

@override
_MyGroupsViewState createState() => _MyGroupsViewState();
}
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/views/groups/new_group_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import 'package:mobile_app/viewmodels/groups/new_group_viewmodel.dart';
class NewGroupView extends StatefulWidget {
static const String id = 'new_group_view';

const NewGroupView({Key key}) : super(key: key);

@override
_NewGroupViewState createState() => _NewGroupViewState();
}
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/views/home/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import 'package:mobile_app/viewmodels/home/home_viewmodel.dart';
class HomeView extends StatefulWidget {
static const String id = 'home_view';

const HomeView({Key key}) : super(key: key);

@override
_HomeViewState createState() => _HomeViewState();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/ib/components/ib_pop_quiz.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class IbPopQuiz extends StatelessWidget {
final BuildContext context;
final List<IbPopQuizQuestion> questions;

const IbPopQuiz({this.context, this.questions});
const IbPopQuiz({Key key, this.context, this.questions}) : super(key: key);

Widget _buildQuestion(int questionNumber, IbPopQuizQuestion question) {
var buttonsWidgets = <Widget>[];
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/views/ib/components/ib_pop_quiz_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ class IbPopQuizButton extends StatefulWidget {
final bool isCorrect;

const IbPopQuizButton({
Key key,
@required this.content,
@required this.isCorrect,
});
}) : super(key: key);

@override
IbPopQuizButtonState createState() => IbPopQuizButtonState();
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/views/ib/ib_landing_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import 'package:theme_provider/theme_provider.dart';
class IbLandingView extends StatefulWidget {
static const String id = 'ib_landing_view';

const IbLandingView({Key key}) : super(key: key);

@override
_IbLandingViewState createState() => _IbLandingViewState();
}
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/views/profile/edit_profile_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import 'package:mobile_app/viewmodels/profile/edit_profile_viewmodel.dart';
class EditProfileView extends StatefulWidget {
static const String id = 'edit_profile_view';

const EditProfileView({Key key}) : super(key: key);

@override
_EditProfileViewState createState() => _EditProfileViewState();
}
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/views/startup_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:mobile_app/ui/views/base_view.dart';
import 'package:mobile_app/viewmodels/startup/startup_viewmodel.dart';

class StartUpView extends StatelessWidget {
const StartUpView({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return BaseView<StartUpViewModel>(
Expand Down
16 changes: 8 additions & 8 deletions lib/utils/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class CVRouter {
static Route<dynamic> generateRoute(RouteSettings settings) {
switch (settings.name) {
case SignupView.id:
return MaterialPageRoute(builder: (_) => SignupView());
return MaterialPageRoute(builder: (_) => const SignupView());
case LoginView.id:
return MaterialPageRoute(builder: (_) => LoginView());
return MaterialPageRoute(builder: (_) => const LoginView());
case ForgotPasswordView.id:
return MaterialPageRoute(builder: (_) => ForgotPasswordView());
return MaterialPageRoute(builder: (_) => const ForgotPasswordView());
case CVLandingView.id:
return MaterialPageRoute(builder: (_) => CVLandingView());
return MaterialPageRoute(builder: (_) => const CVLandingView());
case TeachersView.id:
return MaterialPageRoute(builder: (_) => const TeachersView());
case ContributorsView.id:
Expand All @@ -56,7 +56,7 @@ class CVRouter {
),
);
case EditProfileView.id:
return MaterialPageRoute(builder: (_) => EditProfileView());
return MaterialPageRoute(builder: (_) => const EditProfileView());
case ProjectDetailsView.id:
var _project = settings.arguments as Project;
return MaterialPageRoute(
Expand All @@ -72,7 +72,7 @@ class CVRouter {
),
);
case MyGroupsView.id:
return MaterialPageRoute(builder: (_) => MyGroupsView());
return MaterialPageRoute(builder: (_) => const MyGroupsView());
case GroupDetailsView.id:
var group = settings.arguments as Group;
return MaterialPageRoute(
Expand All @@ -81,7 +81,7 @@ class CVRouter {
),
);
case NewGroupView.id:
return MaterialPageRoute(builder: (_) => NewGroupView());
return MaterialPageRoute(builder: (_) => const NewGroupView());
case EditGroupView.id:
var group = settings.arguments as Group;
return MaterialPageRoute(
Expand Down Expand Up @@ -111,7 +111,7 @@ class CVRouter {
),
);
case IbLandingView.id:
return MaterialPageRoute(builder: (_) => IbLandingView());
return MaterialPageRoute(builder: (_) => const IbLandingView());
case ProjectPreviewFullScreen.id:
var _project = settings.arguments as Project;
return MaterialPageRoute(
Expand Down
2 changes: 1 addition & 1 deletion test/ui_tests/about/about_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void main() {
locale: const Locale('en'),
onGenerateRoute: CVRouter.generateRoute,
navigatorObservers: [mockObserver],
home: AboutView(),
home: const AboutView(),
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void main() {
GetMaterialApp(
onGenerateRoute: CVRouter.generateRoute,
navigatorObservers: [mockObserver],
home: ForgotPasswordView(),
home: const ForgotPasswordView(),
),
);

Expand Down
2 changes: 1 addition & 1 deletion test/ui_tests/authentication/login_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void main() {
GetMaterialApp(
onGenerateRoute: CVRouter.generateRoute,
navigatorObservers: [mockObserver],
home: LoginView(),
home: const LoginView(),
),
);

Expand Down
2 changes: 1 addition & 1 deletion test/ui_tests/authentication/signup_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void main() {
GetMaterialApp(
onGenerateRoute: CVRouter.generateRoute,
navigatorObservers: [mockObserver],
home: SignupView(),
home: const SignupView(),
),
);

Expand Down
2 changes: 1 addition & 1 deletion test/ui_tests/groups/my_groups_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void main() {
GetMaterialApp(
onGenerateRoute: CVRouter.generateRoute,
navigatorObservers: [mockObserver],
home: MyGroupsView(),
home: const MyGroupsView(),
),
);

Expand Down
2 changes: 1 addition & 1 deletion test/ui_tests/groups/new_group_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void main() {
GetMaterialApp(
onGenerateRoute: CVRouter.generateRoute,
navigatorObservers: [mockObserver],
home: NewGroupView(),
home: const NewGroupView(),
),
);

Expand Down
2 changes: 1 addition & 1 deletion test/ui_tests/home/home_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void main() {
GetMaterialApp(
onGenerateRoute: CVRouter.generateRoute,
navigatorObservers: [mockObserver],
home: HomeView(),
home: const HomeView(),
),
);

Expand Down
2 changes: 1 addition & 1 deletion test/ui_tests/ib/ib_landing_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void main() {
GetMaterialApp(
onGenerateRoute: CVRouter.generateRoute,
navigatorObservers: [mockObserver],
home: IbLandingView(),
home: const IbLandingView(),
),
);

Expand Down
2 changes: 1 addition & 1 deletion test/ui_tests/profile/edit_profile_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void main() {
GetMaterialApp(
onGenerateRoute: CVRouter.generateRoute,
navigatorObservers: [mockObserver],
home: EditProfileView(),
home: const EditProfileView(),
),
);

Expand Down
2 changes: 1 addition & 1 deletion test/ui_tests/startup/startup_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void main() {
locale: const Locale('en'),
onGenerateRoute: CVRouter.generateRoute,
navigatorObservers: [mockObserver],
home: StartUpView(),
home: const StartUpView(),
),
);

Expand Down