Skip to content

Commit 0bf3e9a

Browse files
committed
enable flutter linter & reformat code
1 parent 933bab1 commit 0bf3e9a

23 files changed

+138
-90
lines changed

analysis_options.yaml

+24-26
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
# This file configures the static analysis results for your project (errors,
2-
# warnings, and lints).
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
33
#
4-
# This enables the 'recommended' set of lints from `package:lints`.
5-
# This set helps identify many issues that may lead to problems when running
6-
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
7-
# style and format.
8-
#
9-
# If you want a smaller set of lints you can change this to specify
10-
# 'package:lints/core.yaml'. These are just the most critical lints
11-
# (the recommended set includes the core lints).
12-
# The core lints are also what is used by pub.dev for scoring packages.
13-
14-
#include: package:lints/recommended.yaml
15-
16-
# Uncomment the following section to specify additional rules.
17-
18-
# linter:
19-
# rules:
20-
# - camel_case_types
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
217

22-
# analyzer:
23-
# exclude:
24-
# - path/to/excluded/files/**
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
2511

26-
# For more information about the core and recommended set of lints, see
27-
# https://dart.dev/go/core-lints
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at https://dart.dev/lints.
17+
#
18+
# Instead of disabling a lint rule for the entire project in the
19+
# section below, it can also be suppressed for a single line of code
20+
# or a specific dart file by using the `// ignore: name_of_lint` and
21+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22+
# producing the lint.
23+
rules:
24+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
2826

29-
# For additional information about configuring this file, see
30-
# https://dart.dev/guides/language/analysis-options
27+
# Additional information about this file can be found at
28+
# https://dart.dev/guides/language/analysis-options

lib/app/controllers/home_controller.dart

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ import 'package:url_launcher/url_launcher.dart';
55
import 'controller.dart';
66

77
class HomeController extends Controller {
8-
@override
9-
construct(BuildContext context) {
10-
super.construct(context);
11-
}
128

139
onTapDocumentation() async {
1410
await launchUrl(Uri.parse("https://nylo.dev/docs"));
@@ -31,7 +27,7 @@ class HomeController extends Controller {
3127
showAboutDialog(
3228
context: context!,
3329
applicationName: getEnv('APP_NAME'),
34-
applicationIcon: Logo(),
30+
applicationIcon: const Logo(),
3531
applicationVersion: nyloVersion,
3632
);
3733
}

lib/app/models/user.dart

+1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ class User extends Model {
1111
email = data['email'];
1212
}
1313

14+
@override
1415
toJson() => {"name": name, "email": email};
1516
}

lib/app/networking/api_service.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
3-
import '/config/storage_keys.dart';
43
import '/config/decoders.dart';
54
import 'package:nylo_framework/nylo_framework.dart';
65

@@ -28,6 +27,7 @@ class ApiService extends NyApiService {
2827
String get baseUrl => getEnv('API_BASE_URL');
2928

3029
@override
30+
// ignore: overridden_fields
3131
final interceptors = {
3232
if (getEnv('APP_DEBUG') == true)
3333
PrettyDioLogger: PrettyDioLogger()

lib/app/networking/dio/interceptors/bearer_auth_interceptor.dart

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ class BearerAuthInterceptor extends Interceptor {
55
@override
66
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
77
String? userToken = Backpack.instance.read(StorageKey.userToken);
8-
if (userToken != null) {
9-
options.headers.addAll({"Authorization": "Bearer $userToken"});
10-
}
11-
return super.onRequest(options, handler);
8+
options.headers.addAll({"Authorization": "Bearer $userToken"});
9+
return super.onRequest(options, handler);
1210
}
1311

1412
@override
@@ -17,7 +15,7 @@ class BearerAuthInterceptor extends Interceptor {
1715
}
1816

1917
@override
20-
void onError(DioException dioException, ErrorInterceptorHandler handler) {
21-
handler.next(dioException);
18+
void onError(DioException err, ErrorInterceptorHandler handler) {
19+
handler.next(err);
2220
}
2321
}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import 'package:nylo_framework/nylo_framework.dart';
22

33
class ExampleInterceptor extends Interceptor {
4-
@override
5-
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
6-
return super.onRequest(options, handler);
7-
}
84

95
@override
106
void onResponse(Response response, ResponseInterceptorHandler handler) {
117
handler.next(response);
128
}
139

1410
@override
15-
void onError(DioException dioException, ErrorInterceptorHandler handler) {
16-
handler.next(dioException);
11+
void onError(DioException err, ErrorInterceptorHandler handler) {
12+
handler.next(err);
1713
}
1814
}

lib/bootstrap/app.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AppBuild extends StatelessWidget {
2929
Route<dynamic>? Function(RouteSettings settings) onGenerateRoute;
3030

3131
AppBuild({
32-
Key? key,
32+
super.key,
3333
this.initialRoute,
3434
this.title,
3535
this.locale,
@@ -54,7 +54,7 @@ class AppBuild extends StatelessWidget {
5454
this.debugShowCheckedModeBanner = true,
5555
this.shortcuts,
5656
this.actions,
57-
}) : super(key: key);
57+
});
5858

5959
@override
6060
Widget build(BuildContext context) {

lib/config/design.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final TextStyle appFont = GoogleFonts.montserrat();
3030
| Use the Logo() widget or Nylo.getAppLogo() display your logo
3131
| -------------------------------------------------------------------------- */
3232

33-
Widget logo = Logo();
33+
Widget logo = const Logo();
3434
// File: resources/widgets/logo_widget.dart
3535

3636

@@ -40,7 +40,7 @@ Widget logo = Logo();
4040
| Use the Loader() widget or Nylo.getAppLoader() display your loader
4141
| -------------------------------------------------------------------------- */
4242

43-
Widget loader = Loader();
43+
Widget loader = const Loader();
4444
// File: resources/widgets/loader_widget.dart
4545

4646

@@ -53,7 +53,7 @@ Widget loader = Loader();
5353
Widget getToastNotificationWidget({
5454
required ToastNotificationStyleType style,
5555
Function(ToastNotificationStyleMetaHelper helper)? toastNotificationStyleMeta, Function? onDismiss}) {
56-
if (toastNotificationStyleMeta == null) return SizedBox.shrink();
56+
if (toastNotificationStyleMeta == null) return const SizedBox.shrink();
5757

5858
ToastMeta toastMeta = toastNotificationStyleMeta(NyToastNotificationStyleMetaHelper(style));
5959

lib/config/localization.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ final String languageCode = getEnv('DEFAULT_LOCALE', defaultValue: "en");
1919
| Define if you want the application to read the locale from the users
2020
| device settings or as you've defined in the [languageCode].
2121
|-------------------------------------------------------------------------- */
22-
final LocaleType localeType = LocaleType.asDefined; // device, asDefined
22+
const LocaleType localeType = LocaleType.asDefined; // device, asDefined
2323

2424
/* languagesList
2525
| -------------------------------------------------------------------------
2626
| Add a list of supported languages.
2727
|-------------------------------------------------------------------------- */
28-
final List<String> languagesList = const ['en'];
28+
const List<String> languagesList = ['en'];
2929

3030
/* assetsDirectory
3131
| -------------------------------------------------------------------------
3232
| Asset directory for your languages.
3333
|-------------------------------------------------------------------------- */
34-
final String assetsDirectory = 'lang/';
34+
const String assetsDirectory = 'lang/';
3535

3636
/* valuesAsMap
3737
| -------------------------------------------------------------------------

lib/config/toast_notification_styles.dart

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,24 @@ import 'package:nylo_framework/nylo_framework.dart';
77

88
class NyToastNotificationStyleMetaHelper extends ToastNotificationStyleMetaHelper {
99

10-
NyToastNotificationStyleMetaHelper(ToastNotificationStyleType? style) : super(style);
10+
NyToastNotificationStyleMetaHelper(super.style);
1111

12+
@override
1213
onSuccess() {
1314
return ToastMeta.success();
1415
}
1516

17+
@override
1618
onWarning() {
1719
return ToastMeta.warning();
1820
}
1921

22+
@override
2023
onInfo() {
2124
return ToastMeta.info();
2225
}
2326

27+
@override
2428
onDanger() {
2529
return ToastMeta.danger();
2630
}

lib/config/validation_rules.dart

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:nylo_framework/nylo_framework.dart';
21

32
/* Validation Rules
43
| -------------------------------------------------------------------------

lib/resources/pages/home_page.dart

+15-15
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import '/app/controllers/home_controller.dart';
1010
class HomePage extends NyStatefulWidget<HomeController> {
1111
static const path = '/home';
1212

13-
HomePage() : super(path, child: _HomePageState());
13+
HomePage({super.key}) : super(path, child: _HomePageState());
1414
}
1515

1616
class _HomePageState extends NyState<HomePage> {
@@ -47,7 +47,7 @@ class _HomePageState extends NyState<HomePage> {
4747
actions: [
4848
IconButton(
4949
onPressed: widget.controller.showAbout,
50-
icon: Icon(Icons.info_outline),
50+
icon: const Icon(Icons.info_outline),
5151
),
5252
],
5353
),
@@ -57,26 +57,26 @@ class _HomePageState extends NyState<HomePage> {
5757
crossAxisAlignment: CrossAxisAlignment.center,
5858
mainAxisAlignment: MainAxisAlignment.center,
5959
children: [
60-
Logo(),
60+
const Logo(),
6161
Text(
6262
getEnv("APP_NAME"),
6363
).displayMedium(context),
64-
Text("Micro-framework for Flutter", textAlign: TextAlign.center)
64+
const Text("Micro-framework for Flutter", textAlign: TextAlign.center)
6565
.titleMedium(context)
6666
.setColor(context, (color) => color.primaryAccent),
67-
Text(
67+
const Text(
6868
"Build something amazing 💡",
6969
).bodyMedium(context).alignCenter(),
7070
Column(
7171
crossAxisAlignment: CrossAxisAlignment.center,
7272
mainAxisAlignment: MainAxisAlignment.start,
7373
children: <Widget>[
74-
Divider(),
74+
const Divider(),
7575
Container(
7676
height: 250,
7777
width: double.infinity,
78-
margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
79-
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
78+
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
79+
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
8080
decoration: BoxDecoration(
8181
color: ThemeColor.get(context).surfaceBackground,
8282
borderRadius: BorderRadius.circular(8),
@@ -85,7 +85,7 @@ class _HomePageState extends NyState<HomePage> {
8585
color: Colors.grey.withOpacity(0.1),
8686
spreadRadius: 1,
8787
blurRadius: 9,
88-
offset: Offset(0, 3),
88+
offset: const Offset(0, 3),
8989
),
9090
]),
9191
child: Center(
@@ -95,38 +95,38 @@ class _HomePageState extends NyState<HomePage> {
9595
children:
9696
ListTile.divideTiles(context: context, tiles: [
9797
MaterialButton(
98+
onPressed: widget.controller.onTapDocumentation,
9899
child: Text(
99100
"documentation".tr().capitalize(),
100101
).bodyLarge(context).setColor(
101102
context, (color) => color.surfaceContent),
102-
onPressed: widget.controller.onTapDocumentation,
103103
),
104104
MaterialButton(
105-
child: Text(
105+
onPressed: widget.controller.onTapGithub,
106+
child: const Text(
106107
"GitHub",
107108
).bodyLarge(context).setColor(
108109
context, (color) => color.surfaceContent),
109-
onPressed: widget.controller.onTapGithub,
110110
),
111111
MaterialButton(
112+
onPressed: widget.controller.onTapChangeLog,
112113
child: Text(
113114
"changelog".tr().capitalize(),
114115
).bodyLarge(context).setColor(
115116
context, (color) => color.surfaceContent),
116-
onPressed: widget.controller.onTapChangeLog,
117117
),
118118
MaterialButton(
119+
onPressed: widget.controller.onTapYouTube,
119120
child: Text(
120121
"YouTube Channel".tr().capitalize(),
121122
).bodyLarge(context).setColor(
122123
context, (color) => color.surfaceContent),
123-
onPressed: widget.controller.onTapYouTube,
124124
),
125125
]).toList(),
126126
),
127127
),
128128
),
129-
Text(
129+
const Text(
130130
"Framework Version: $nyloVersion",
131131
)
132132
.bodyMedium(context)

lib/resources/themes/dark_theme.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ThemeData darkTheme(ColorStyles color) {
6161

6262
TextTheme _textTheme(ColorStyles colors) {
6363
Color primaryContent = colors.primaryContent;
64-
TextTheme textTheme = TextTheme().apply(displayColor: primaryContent);
64+
TextTheme textTheme = const TextTheme().apply(displayColor: primaryContent);
6565
return textTheme.copyWith(
6666
titleLarge: TextStyle(color: primaryContent.withOpacity(0.8)),
6767
labelLarge: TextStyle(color: primaryContent.withOpacity(0.8)),

lib/resources/themes/light_theme.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ ThemeData lightTheme(ColorStyles color) {
6666

6767
TextTheme _textTheme(ColorStyles colors) {
6868
Color primaryContent = colors.primaryContent;
69-
TextTheme textTheme = TextTheme().apply(displayColor: primaryContent);
69+
TextTheme textTheme = const TextTheme().apply(displayColor: primaryContent);
7070
return textTheme.copyWith(
7171
labelLarge: TextStyle(color: primaryContent.withOpacity(0.8)));
7272
}

0 commit comments

Comments
 (0)