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): prefer const declarations #155

Merged
merged 1 commit into from
Oct 11, 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
13 changes: 1 addition & 12 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@ linter:
# Unnecessary use of this in constructors should not be done
unnecessary_this: false

# source files name using lowercase_with_underscores
lowercase_with_underscores: true

leading_newlines_in_multiline_strings: false

type_annotate_public_apis: false
#always_use_package_imports to make a quick navigation to particular files
always_use_package_imports: true


directives_ordering: false

avoid_function_literals_in_foreach_calls: false
Expand All @@ -36,8 +31,6 @@ linter:

prefer_const_literals_to_create_immutables: false

prefer_const_constructors: false

prefer_function_declarations_over_variables: false

unnecessary_string_escapes: false
Expand All @@ -46,12 +39,8 @@ linter:

use_key_in_widget_constructors: false

prefer_const_declarations: false

constant_identifier_names: false

sized_box_for_whitespace: false

prefer_typing_uninitialized_variables: false

prefer_const_constructors_in_immutables: true
2 changes: 1 addition & 1 deletion lib/ib_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class IbTheme {
primaryIconTheme: Theme.of(context).primaryIconTheme.copyWith(
color: Colors.white,
),
appBarTheme: AppBarTheme(
appBarTheme: const AppBarTheme(
foregroundColor: Colors.white,
backgroundColor: IbTheme.primaryColor,
),
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CircuitVerseMobile extends StatelessWidget {
data: ThemeData(
fontFamily: 'Poppins',
brightness: Brightness.light,
textSelectionTheme: TextSelectionThemeData(
textSelectionTheme: const TextSelectionThemeData(
cursorColor: CVTheme.primaryColor,
),
appBarTheme: AppBarTheme(
Expand All @@ -59,7 +59,7 @@ class CircuitVerseMobile extends StatelessWidget {
data: ThemeData(
fontFamily: 'Poppins',
brightness: Brightness.dark,
textSelectionTheme: TextSelectionThemeData(
textSelectionTheme: const TextSelectionThemeData(
cursorColor: CVTheme.primaryColor,
),
),
Expand Down
16 changes: 8 additions & 8 deletions lib/services/dialog_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DialogService {
),
title: Text(
request.title,
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
Expand All @@ -29,7 +29,7 @@ class DialogService {
},
child: Text(
request.buttonTitle,
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
Expand All @@ -47,7 +47,7 @@ class DialogService {
),
title: Text(
request.title,
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
Expand All @@ -59,7 +59,7 @@ class DialogService {
},
child: Text(
request.cancelTitle,
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
Expand All @@ -70,7 +70,7 @@ class DialogService {
},
child: Text(
request.buttonTitle,
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
Expand All @@ -92,12 +92,12 @@ class DialogService {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
CircularProgressIndicator(),
SizedBox(width: 16),
const CircularProgressIndicator(),
const SizedBox(width: 16),
Expanded(
child: Text(
request.title,
style: TextStyle(fontSize: 18),
style: const TextStyle(fontSize: 18),
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/components/cv_add_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CVAddIconButton extends StatelessWidget {
Widget build(BuildContext context) {
return IconButton(
padding: const EdgeInsets.all(0),
icon: Icon(
icon: const Icon(
Icons.add_circle_outline,
color: CVTheme.grey,
size: 36,
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/components/cv_social_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CircuitVerseSocialCard extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Image.asset(imagePath, width: 48),
SizedBox(width: 16),
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
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 @@ -14,7 +14,7 @@ class CVTabBar extends StatelessWidget implements PreferredSizeWidget {
return Container(
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.vertical(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(4),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/about/about_tos_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AboutTosView extends StatelessWidget {

TextSpan _buildLink(String text, String link, {bool route = false}) {
return TextSpan(
style: TextStyle(
style: const TextStyle(
color: Colors.blue,
fontFamily: 'Poppins',
),
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/views/about/about_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class _AboutViewState extends State<AboutView> {
onPressed: () => Get.toNamed(AboutTosView.id),
),
),
SizedBox(width: 8),
const SizedBox(width: 8),
Expanded(
child: CVPrimaryButton(
title: AppLocalizations.of(context).privacy_policy,
Expand Down Expand Up @@ -117,7 +117,7 @@ class _AboutViewState extends State<AboutView> {
description: AppLocalizations.of(context).slack_channel,
url: 'https://circuitverse.org/slack',
),
Divider(),
const Divider(),
CVSubheader(
title: AppLocalizations.of(context).contributors,
subtitle: AppLocalizations.of(context).contributors_subtitle,
Expand Down
12 changes: 6 additions & 6 deletions lib/ui/views/authentication/components/auth_options_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class _AuthOptionsViewState extends State<AuthOptionsView> {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Row(children: <Widget>[
Expanded(child: Divider(thickness: 1)),
const Expanded(child: Divider(thickness: 1)),
Text(' Or ${widget.isSignUp ? 'SignUp' : 'Login'} with '),
Expanded(child: Divider(thickness: 1)),
const Expanded(child: Divider(thickness: 1)),
]),
),
Row(
Expand All @@ -78,7 +78,7 @@ class _AuthOptionsViewState extends State<AuthOptionsView> {
onTap: onGoogleAuthPressed,
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(shape: BoxShape.circle),
decoration: const BoxDecoration(shape: BoxShape.circle),
child:
Image.asset('assets/icons/google_icon.png', height: 40),
),
Expand All @@ -87,7 +87,7 @@ class _AuthOptionsViewState extends State<AuthOptionsView> {
onTap: onFacebookAuthPressed,
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(shape: BoxShape.circle),
decoration: const BoxDecoration(shape: BoxShape.circle),
child:
Image.asset('assets/icons/facebook_icon.png', height: 40),
),
Expand All @@ -96,8 +96,8 @@ class _AuthOptionsViewState extends State<AuthOptionsView> {
onTap: onGithubAuthPressed,
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(shape: BoxShape.circle),
child: Icon(FontAwesome5.github, size: 40),
decoration: const BoxDecoration(shape: BoxShape.circle),
child: const Icon(FontAwesome5.github, size: 40),
),
),
],
Expand Down
14 changes: 7 additions & 7 deletions lib/ui/views/authentication/forgot_password_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class _ForgotPasswordViewState extends State<ForgotPasswordView> {
text: 'New User? ',
style: Theme.of(context).textTheme.bodyText1,
children: <TextSpan>[
TextSpan(
const TextSpan(
text: 'Sign Up',
style: TextStyle(
color: CVTheme.primaryColorDark,
Expand Down Expand Up @@ -102,7 +102,7 @@ class _ForgotPasswordViewState extends State<ForgotPasswordView> {
);

// route back to previous screen
await Future.delayed(Duration(seconds: 1));
await Future.delayed(const Duration(seconds: 1));
Get.back();
} else if (_model.isError(_model.SEND_RESET_INSTRUCTIONS)) {
// show failure snackbar
Expand All @@ -126,14 +126,14 @@ class _ForgotPasswordViewState extends State<ForgotPasswordView> {
child: Column(
children: <Widget>[
_buildForgotPasswordImage(),
SizedBox(height: 8),
const SizedBox(height: 8),
_buildEmailInput(),
SizedBox(height: 8),
const SizedBox(height: 8),
_buildSendInstructionsButton(),
SizedBox(height: 8),
const SizedBox(height: 8),
_buildNewUserSignUpComponent(),
SizedBox(height: 32),
AuthOptionsView(
const SizedBox(height: 32),
const AuthOptionsView(
isSignUp: false,
),
],
Expand Down
12 changes: 6 additions & 6 deletions lib/ui/views/authentication/login_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class _LoginViewState extends State<LoginView> {
);

// move to home view on successful login..
await Future.delayed(Duration(seconds: 1));
await Future.delayed(const Duration(seconds: 1));
await Get.offAllNamed(CVLandingView.id);
} else if (_model.isError(_model.LOGIN)) {
// show failure snackbar..
Expand All @@ -152,16 +152,16 @@ class _LoginViewState extends State<LoginView> {
child: Column(
children: <Widget>[
_buildLoginImage(),
SizedBox(height: 8),
const SizedBox(height: 8),
_buildEmailInput(),
_buildPasswordInput(),
_buildForgotPasswordComponent(),
SizedBox(height: 16),
const SizedBox(height: 16),
_buildLoginButton(),
SizedBox(height: 8),
const SizedBox(height: 8),
_buildNewUserSignUpComponent(),
SizedBox(height: 32),
AuthOptionsView(isSignUp: false),
const SizedBox(height: 32),
const AuthOptionsView(isSignUp: false),
],
),
),
Expand Down
12 changes: 6 additions & 6 deletions lib/ui/views/authentication/signup_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class _SignupViewState extends State<SignupView> {

// move to home view on successful signup..
await Future.delayed(
Duration(seconds: 1),
const Duration(seconds: 1),
);
await Get.offAllNamed(CVLandingView.id);
} else if (_signUpModel.isError(_signUpModel.SIGNUP)) {
Expand All @@ -155,16 +155,16 @@ class _SignupViewState extends State<SignupView> {
child: Column(
children: <Widget>[
_buildSignUpImage(),
SizedBox(height: 8),
const SizedBox(height: 8),
_buildNameInput(),
_buildEmailInput(),
_buildPasswordInput(),
SizedBox(height: 16),
const SizedBox(height: 16),
_buildRegisterButton(),
SizedBox(height: 8),
const SizedBox(height: 8),
_buildAlreadyRegisteredComponent(),
SizedBox(height: 32),
AuthOptionsView(isSignUp: true),
const SizedBox(height: 32),
const AuthOptionsView(isSignUp: true),
],
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ class ContributeDonateCard extends StatelessWidget {
title,
style: Theme.of(context).textTheme.headline6,
),
SizedBox(height: 10),
const SizedBox(height: 10),
GestureDetector(
onTap: () async {
launchURL(url);
},
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black, width: 2),
borderRadius: BorderRadius.all(
borderRadius: const BorderRadius.all(
Radius.circular(8),
),
color: Colors.white,
boxShadow: [
BoxShadow(
const BoxShadow(
color: Colors.grey,
blurRadius: 2.0,
offset: Offset(2.0, 2.0),
Expand All @@ -43,7 +43,7 @@ class ContributeDonateCard extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: ClipRRect(
borderRadius: BorderRadius.all(
borderRadius: const BorderRadius.all(
Radius.circular(8),
),
child: Image.asset(
Expand Down
Loading