Skip to content

Commit 07c090f

Browse files
committed
Run Dart Analyzer
- Run Dart Analyzer fixes. - Add flutter_lints.
1 parent 9ef60f1 commit 07c090f

11 files changed

+439
-401
lines changed

analysis_options.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
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`.
7+
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
11+
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
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27+
28+
# Additional information about this file can be found at
29+
# https://dart.dev/guides/language/analysis-options

lib/responsive_grid.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ResponsiveGridView extends StatelessWidget {
3939
final Clip clipBehavior;
4040
final String? restorationId;
4141

42-
ResponsiveGridView.builder({
42+
const ResponsiveGridView.builder({
4343
Key? key,
4444
this.scrollDirection = Axis.vertical,
4545
this.reverse = false,
@@ -62,7 +62,7 @@ class ResponsiveGridView extends StatelessWidget {
6262
this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
6363
this.clipBehavior = Clip.hardEdge,
6464
this.restorationId,
65-
});
65+
}) : super(key: key);
6666

6767
@override
6868
Widget build(BuildContext context) {
@@ -128,7 +128,7 @@ class ResponsiveGridView extends StatelessWidget {
128128
alignment == Alignment.topLeft ||
129129
alignment == Alignment.bottomLeft) {
130130
// Align left, no padding.
131-
alignmentPadding = EdgeInsets.only(left: 0);
131+
alignmentPadding = const EdgeInsets.only(left: 0);
132132
} else if (alignment == Alignment.center ||
133133
alignment == Alignment.topCenter ||
134134
alignment == Alignment.bottomCenter) {
@@ -137,7 +137,7 @@ class ResponsiveGridView extends StatelessWidget {
137137
double paddingCalc = constraints.maxWidth - crossAxisWidth;
138138
if (paddingCalc <= 0) {
139139
// There is no additional space. No padding.
140-
alignmentPadding = EdgeInsets.only(left: 0);
140+
alignmentPadding = const EdgeInsets.only(left: 0);
141141
} else if (paddingCalc > gridDelegate.crossAxisSpacing) {
142142
// There is enough room to center items correctly.
143143
// Add padding equivalent to the last item to the first item.
@@ -200,7 +200,7 @@ class _ResponsiveGridViewLayout extends BoxScrollView {
200200
final SliverChildDelegate childrenDelegate;
201201
final int? itemCount;
202202

203-
_ResponsiveGridViewLayout({
203+
const _ResponsiveGridViewLayout({
204204
Key? key,
205205
Axis scrollDirection = Axis.vertical,
206206
bool reverse = false,
@@ -302,15 +302,15 @@ class ResponsiveGridDelegate extends SliverGridDelegate {
302302
// Item width.
303303
double? childCrossAxisExtent;
304304
// Switch between item sizing behaviors.
305-
if (this.crossAxisExtent != null) {
305+
if (crossAxisExtent != null) {
306306
crossAxisCount =
307307
(constraints.crossAxisExtent / (crossAxisExtent! + crossAxisSpacing))
308308
.floor();
309309
childCrossAxisExtent = crossAxisExtent;
310310
childMainAxisExtent = childCrossAxisExtent! / childAspectRatio;
311311
mainAxisStride = childMainAxisExtent + mainAxisSpacing;
312312
crossAxisStride = childCrossAxisExtent + crossAxisSpacing;
313-
} else if (this.maxCrossAxisExtent != null) {
313+
} else if (maxCrossAxisExtent != null) {
314314
crossAxisCount = (constraints.crossAxisExtent /
315315
(maxCrossAxisExtent! + crossAxisSpacing))
316316
.ceil();

lib/responsive_row_column.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: constant_identifier_names
2+
13
import 'package:flutter/cupertino.dart';
24
import 'package:flutter/widgets.dart';
35

@@ -67,7 +69,7 @@ class ResponsiveRowColumn extends StatelessWidget {
6769

6870
@override
6971
Widget build(BuildContext context) {
70-
if (layout == ResponsiveRowColumnType.ROW)
72+
if (layout == ResponsiveRowColumnType.ROW) {
7173
return Padding(
7274
padding: rowPadding,
7375
child: Row(
@@ -82,6 +84,7 @@ class ResponsiveRowColumn extends StatelessWidget {
8284
],
8385
),
8486
);
87+
}
8588

8689
return Padding(
8790
padding: columnPadding,
@@ -115,11 +118,12 @@ class ResponsiveRowColumn extends StatelessWidget {
115118
List<Widget> widgetList = [];
116119
for (int i = 0; i < childrenHolder.length; i++) {
117120
widgetList.add(childrenHolder[i].copyWith(rowColumn: rowColumn));
118-
if (spacing != null && i != childrenHolder.length - 1)
121+
if (spacing != null && i != childrenHolder.length - 1) {
119122
widgetList.add(Padding(
120123
padding: rowColumn
121124
? EdgeInsets.only(right: spacing)
122125
: EdgeInsets.only(bottom: spacing)));
126+
}
123127
}
124128
return widgetList;
125129
}
@@ -187,7 +191,7 @@ class ResponsiveRowColumnItem extends StatelessWidget {
187191
rowColumn: rowColumn ?? this.rowColumn,
188192
rowFlex: rowFlex ?? this.rowFlex,
189193
columnFlex: columnFlex ?? this.columnFlex,
190-
rowFit: rowFlexFit ?? this.rowFit,
191-
columnFit: columnFlexFit ?? this.columnFit,
194+
rowFit: rowFlexFit ?? rowFit,
195+
columnFit: columnFlexFit ?? columnFit,
192196
);
193197
}

lib/responsive_value.dart

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: constant_identifier_names
2+
13
import 'package:collection/collection.dart' show IterableExtension;
24
import 'package:flutter/widgets.dart';
35

@@ -66,8 +68,9 @@ class ResponsiveValue<T> {
6668
if (activeCondition == null) return null;
6769
// Return landscape value if orientation is landscape and landscape override value is provided.
6870
if (ResponsiveWrapper.of(context).orientation == Orientation.landscape &&
69-
activeCondition.landscapeValue != null)
71+
activeCondition.landscapeValue != null) {
7072
return activeCondition.landscapeValue;
73+
}
7174
// Return active condition value or default value if null.
7275
return activeCondition.value;
7376
}
@@ -159,28 +162,17 @@ class Condition<T> {
159162
: assert(breakpoint != null || name != null),
160163
assert((condition == Conditional.EQUALS) ? name != null : true);
161164

162-
const Condition.equals({required String name, T? value, T? landscapeValue})
163-
: this.breakpoint = null,
164-
this.name = name,
165-
this.condition = Conditional.EQUALS,
166-
this.value = value,
167-
this.landscapeValue = landscapeValue;
165+
const Condition.equals({required this.name, this.value, this.landscapeValue})
166+
: breakpoint = null,
167+
condition = Conditional.EQUALS;
168168

169169
const Condition.largerThan(
170-
{int? breakpoint, String? name, T? value, T? landscapeValue})
171-
: this.breakpoint = breakpoint,
172-
this.name = name,
173-
this.condition = Conditional.LARGER_THAN,
174-
this.value = value,
175-
this.landscapeValue = landscapeValue;
170+
{this.breakpoint, this.name, this.value, this.landscapeValue})
171+
: condition = Conditional.LARGER_THAN;
176172

177173
const Condition.smallerThan(
178-
{int? breakpoint, String? name, T? value, T? landscapeValue})
179-
: this.breakpoint = breakpoint,
180-
this.name = name,
181-
this.condition = Conditional.SMALLER_THAN,
182-
this.value = value,
183-
this.landscapeValue = landscapeValue;
174+
{this.breakpoint, this.name, this.value, this.landscapeValue})
175+
: condition = Conditional.SMALLER_THAN;
184176

185177
Condition copyWith({
186178
int? breakpoint,
@@ -199,8 +191,7 @@ class Condition<T> {
199191

200192
@override
201193
String toString() =>
202-
'Condition(' +
203-
'breakpoint: ' +
194+
'Condition(' 'breakpoint: ' +
204195
breakpoint.toString() +
205196
', name: ' +
206197
name.toString() +

0 commit comments

Comments
 (0)