Skip to content

Commit b1a8d9b

Browse files
saileshbroibhavikmakwana
authored andcommitted
feat: add linting rules and linted the project
1 parent 763da64 commit b1a8d9b

File tree

52 files changed

+396
-393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+396
-393
lines changed

analysis_options.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
include: package:lint/analysis_options.yaml
2+
analyzer:
3+
errors:
4+
missing_required_param: error
5+
missing_return: error
6+
must_be_immutable: error
7+
parameter_assignments: error
8+
sort_pub_dependencies: ignore
9+
sort_unnamed_constructors_first: warning
10+
avoid_print: ignore
11+
file_names: ignore
12+
avoid_function_literals_in_foreach_calls: ignore
13+
argument_type_not_assignable: error
14+
unnecessary_getters_setters: error
15+
unnecessary_raw_strings: error
16+
prefer_constructors_over_static_methods: error
17+
exclude:
18+
- "**/*.locator.dart"
19+
- "**/*.router.dart"
20+
- "**/*.logger.dart"
21+
- "**/*.form.dart"
22+
- "**/*.g.dart"
23+
linter:
24+
rules:
25+
parameter_assignments: true
26+
always_use_package_imports: true

lib/ExampleNameItem.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ class ExampleNameItem extends StatelessWidget {
2424
borderRadius: BorderRadius.circular(4.0),
2525
child: Card(
2626
elevation: 4.0,
27-
shape: const RoundedRectangleBorder(
28-
borderRadius: BorderRadius.all(Radius.circular(0.0)),
29-
),
27+
shape: const RoundedRectangleBorder(),
3028
child: Container(
3129
decoration: BoxDecoration(
3230
border: Border(
@@ -44,13 +42,11 @@ class ExampleNameItem extends StatelessWidget {
4442
},
4543
child: Row(
4644
mainAxisAlignment: MainAxisAlignment.spaceBetween,
47-
crossAxisAlignment: CrossAxisAlignment.center,
48-
mainAxisSize: MainAxisSize.max,
4945
children: <Widget>[
5046
Expanded(
5147
child: Container(
52-
margin:
53-
EdgeInsets.symmetric(vertical: 16.0, horizontal: 8.0),
48+
margin: const EdgeInsets.symmetric(
49+
vertical: 16.0, horizontal: 8.0),
5450
child: Text(
5551
exampleNames.title,
5652
softWrap: true,
@@ -59,8 +55,8 @@ class ExampleNameItem extends StatelessWidget {
5955
),
6056
),
6157
),
62-
Padding(
63-
padding: const EdgeInsets.all(8.0),
58+
const Padding(
59+
padding: EdgeInsets.all(8.0),
6460
child: Icon(
6561
Icons.chevron_right,
6662
),

lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import 'package:flutter/material.dart';
66
import 'package:flutter_playground/store/theme_store.dart';
77
import 'package:provider/provider.dart';
88

9-
import 'my_app.dart';
10-
import 'values/imports.dart';
9+
import 'package:flutter_playground/my_app.dart';
10+
import 'package:flutter_playground/values/imports.dart';
1111

1212
void main() {
1313
return runApp(

lib/my_app.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import 'package:flutter_playground/values/routes.dart';
77
import 'package:google_fonts/google_fonts.dart';
88
import 'package:provider/provider.dart';
99

10-
import 'store/theme_store.dart';
11-
import 'ui_ux/home_page/my_home_page_store.dart';
12-
import 'utils/Strings.dart';
10+
import 'package:flutter_playground/store/theme_store.dart';
11+
import 'package:flutter_playground/ui_ux/home_page/my_home_page_store.dart';
12+
import 'package:flutter_playground/utils/Strings.dart';
1313

1414
class MyApp extends StatelessObserverWidget {
1515
static FirebaseAnalytics analytics = FirebaseAnalytics();
1616
static FirebaseAnalyticsObserver observer =
17-
FirebaseAnalyticsObserver(analytics: analytics);
17+
FirebaseAnalyticsObserver(analytics: analytics);
1818

1919
@override
2020
Widget build(BuildContext context) {
@@ -32,7 +32,7 @@ class MyApp extends StatelessObserverWidget {
3232
debugShowCheckedModeBanner: false,
3333
home: Provider(
3434
create: (context) => MyHomePageStore()..initList(),
35-
child: MyHomePage(title: Strings.appName),
35+
child: const MyHomePage(title: Strings.appName),
3636
),
3737
routes: DefaultRoutes.routes(),
3838
);

lib/store/theme_store.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ abstract class _ThemeStore with Store {
1010
ThemeMode themeMode = ThemeMode.light;
1111

1212
@action
13-
changeTheme() {
13+
void changeTheme() {
1414
themeMode == ThemeMode.light
1515
? themeMode = ThemeMode.dark
1616
: themeMode = ThemeMode.light;

lib/ui/aboutlisttile/AboutListTileExample.dart

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
77
class AboutListTileExample extends StatefulWidget {
88
final String title;
99

10-
AboutListTileExample({Key? key, required this.title}) : super(key: key);
10+
const AboutListTileExample({Key? key, required this.title}) : super(key: key);
1111

1212
@override
1313
_AboutListTileState createState() => _AboutListTileState();
@@ -20,21 +20,19 @@ class _AboutListTileState extends State<AboutListTileExample> {
2020
appBar: AppBar(
2121
title: Text(widget.title),
2222
),
23-
body: Container(
24-
child: Column(
25-
children: <Widget>[
26-
AboutListTile(
27-
icon: FlutterLogo(),
28-
child: Text("About"),
29-
aboutBoxChildren: <Widget>[
30-
Text("Playground app for Flutter. Contains list of examples."),
31-
],
32-
applicationIcon: FlutterLogo(),
33-
applicationName: "Flutter Playground",
34-
applicationVersion: "1.0.0",
35-
),
36-
],
37-
),
23+
body: Column(
24+
children: const <Widget>[
25+
AboutListTile(
26+
icon: FlutterLogo(),
27+
aboutBoxChildren: <Widget>[
28+
Text("Playground app for Flutter. Contains list of examples."),
29+
],
30+
applicationIcon: FlutterLogo(),
31+
applicationName: "Flutter Playground",
32+
applicationVersion: "1.0.0",
33+
child: Text("About"),
34+
),
35+
],
3836
),
3937
);
4038
}

lib/ui/animated_crossfade/animated_cross_fade.dart

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
77
class AnimatedCrossFadeExample extends StatefulWidget {
88
final String title;
99

10-
AnimatedCrossFadeExample(this.title);
10+
const AnimatedCrossFadeExample(this.title);
1111

1212
@override
1313
_AnimatedCrossFadeExampleState createState() =>
@@ -23,32 +23,28 @@ class _AnimatedCrossFadeExampleState extends State<AnimatedCrossFadeExample> {
2323
appBar: AppBar(
2424
title: Text(widget.title),
2525
),
26-
body: Container(
27-
child: Center(
28-
child: Column(
29-
children: <Widget>[
30-
TextButton(
31-
onPressed: () {
32-
setState(() {
33-
_first = !_first;
34-
});
35-
},
36-
child: Text("Click")),
37-
AnimatedCrossFade(
38-
sizeCurve: ElasticOutCurve(),
39-
firstCurve: Curves.decelerate,
40-
secondCurve: Curves.decelerate,
41-
duration: const Duration(seconds: 3),
42-
firstChild: const FlutterLogo(
43-
style: FlutterLogoStyle.horizontal, size: 100.0),
44-
secondChild: const FlutterLogo(
45-
style: FlutterLogoStyle.markOnly, size: 100.0),
46-
crossFadeState: _first
47-
? CrossFadeState.showFirst
48-
: CrossFadeState.showSecond,
49-
),
50-
],
51-
),
26+
body: Center(
27+
child: Column(
28+
children: <Widget>[
29+
TextButton(
30+
onPressed: () {
31+
setState(() {
32+
_first = !_first;
33+
});
34+
},
35+
child: const Text("Click")),
36+
AnimatedCrossFade(
37+
sizeCurve: const ElasticOutCurve(),
38+
firstCurve: Curves.decelerate,
39+
secondCurve: Curves.decelerate,
40+
duration: const Duration(seconds: 3),
41+
firstChild: const FlutterLogo(
42+
style: FlutterLogoStyle.horizontal, size: 100.0),
43+
secondChild: const FlutterLogo(size: 100.0),
44+
crossFadeState:
45+
_first ? CrossFadeState.showFirst : CrossFadeState.showSecond,
46+
),
47+
],
5248
),
5349
),
5450
);

lib/ui/animatedicons/AnimatedIcons.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import 'package:flutter/material.dart';
66

77
class AnimatedIconsDemo extends StatefulWidget {
8-
AnimatedIconsDemo({Key? key, required this.title}) : super(key: key);
8+
const AnimatedIconsDemo({Key? key, required this.title}) : super(key: key);
99

1010
// This widget is the home page of your application. It is stateful, meaning
1111
// that it has a State object (defined below) that contains fields that affect
@@ -76,7 +76,7 @@ class _AnimatedIconsState extends State<AnimatedIconsDemo>
7676
);
7777
}
7878

79-
getAnimatedIcon(AnimatedIconData iconData, String title) {
79+
Widget getAnimatedIcon(AnimatedIconData iconData, String title) {
8080
return Padding(
8181
padding: const EdgeInsets.all(8.0),
8282
child: InkWell(

lib/ui/animatedsize/AnimatedSize.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import 'package:flutter/material.dart';
66

77
class AnimatedSizeDemo extends StatefulWidget {
8-
AnimatedSizeDemo({Key? key, required this.title}) : super(key: key);
8+
const AnimatedSizeDemo({Key? key, required this.title}) : super(key: key);
99
final String title;
1010

1111
@override
@@ -31,6 +31,8 @@ class _AnimatedSizeDemoState extends State<AnimatedSizeDemo>
3131
children: <Widget>[
3232
AnimatedSize(
3333
curve: Curves.bounceInOut,
34+
vsync: this,
35+
duration: const Duration(seconds: 1),
3436
child: GestureDetector(
3537
onTap: () {
3638
setState(() {
@@ -53,8 +55,6 @@ class _AnimatedSizeDemoState extends State<AnimatedSizeDemo>
5355
color: _color,
5456
),
5557
),
56-
vsync: this,
57-
duration: Duration(seconds: 1),
5858
),
5959
],
6060
),

lib/ui/animatedswitcher/AnimatedSwitcherExample.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import 'package:flutter/material.dart';
66

77
class AnimatedSwitcherExample extends StatefulWidget {
8-
AnimatedSwitcherExample({Key? key, required this.title}) : super(key: key);
8+
const AnimatedSwitcherExample({Key? key, required this.title})
9+
: super(key: key);
910

1011
final String title;
1112

@@ -35,14 +36,17 @@ class _AnimatedSwitcherExampleState extends State<AnimatedSwitcherExample> {
3536
children: <Widget>[
3637
Column(
3738
children: <Widget>[
38-
Text(
39+
const Text(
3940
'You have pushed the button this many times:',
4041
),
4142
AnimatedSwitcher(
4243
duration: const Duration(milliseconds: 500),
4344
transitionBuilder:
4445
(Widget child, Animation<double> animation) {
45-
return ScaleTransition(child: child, scale: animation);
46+
return ScaleTransition(
47+
scale: animation,
48+
child: child,
49+
);
4650
},
4751
child: Text(
4852
'$_counter',
@@ -61,7 +65,7 @@ class _AnimatedSwitcherExampleState extends State<AnimatedSwitcherExample> {
6165
floatingActionButton: FloatingActionButton(
6266
onPressed: _incrementCounter,
6367
tooltip: 'Increment',
64-
child: Icon(Icons.add),
68+
child: const Icon(Icons.add),
6569
),
6670
);
6771
}

0 commit comments

Comments
 (0)