Skip to content

Commit 30dbda8

Browse files
committed
🚨 Add require_trailing_commas lint
1 parent 67a9ca9 commit 30dbda8

File tree

5 files changed

+57
-32
lines changed

5 files changed

+57
-32
lines changed

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ linter:
169169
# - provide_deprecation_message # not yet tested
170170
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
171171
- recursive_getters
172+
- require_trailing_commas
172173
# - sized_box_for_whitespace # not yet tested
173174
- slash_for_doc_comments
174175
# - sort_child_properties_last # not yet tested

example/lib/main.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ PackageInfo? packageInfo;
1818

1919
void main() {
2020
runApp(MyApp());
21-
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
22-
statusBarColor: Colors.transparent,
23-
));
21+
SystemChrome.setSystemUIOverlayStyle(
22+
SystemUiOverlayStyle.dark.copyWith(statusBarColor: Colors.transparent),
23+
);
2424
AssetPicker.registerObserve();
2525
}
2626

@@ -62,6 +62,9 @@ class NoGlowScrollBehavior extends ScrollBehavior {
6262

6363
@override
6464
Widget buildViewportChrome(
65-
BuildContext context, Widget child, AxisDirection axisDirection) =>
65+
BuildContext context,
66+
Widget child,
67+
AxisDirection axisDirection,
68+
) =>
6669
child;
6770
}

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,13 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
472472
bottom: context.bottomPadding,
473473
),
474474
color: theme.primaryColor.withOpacity(isAppleOS ? 0.90 : 1),
475-
child: Row(children: <Widget>[
476-
if (!isSingleAssetMode || !isAppleOS) previewButton(context),
477-
if (isAppleOS) const Spacer(),
478-
if (isAppleOS) confirmButton(context),
479-
]),
475+
child: Row(
476+
children: <Widget>[
477+
if (!isSingleAssetMode || !isAppleOS) previewButton(context),
478+
if (isAppleOS) const Spacer(),
479+
if (isAppleOS) confirmButton(context),
480+
],
481+
),
480482
);
481483
if (isPermissionLimited) {
482484
child = Column(

lib/src/provider/asset_picker_provider.dart

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -367,22 +367,24 @@ class DefaultAssetPickerProvider
367367

368368
@override
369369
Future<void> switchPath([AssetPathEntity? pathEntity]) async {
370-
assert(() {
371-
if (_currentPathEntity == null && pathEntity == null) {
372-
throw FlutterError.fromParts(<DiagnosticsNode>[
373-
ErrorSummary('Empty $AssetPathEntity was switched.'),
374-
ErrorDescription(
375-
'Neither currentPathEntity nor pathEntity is non-null, which makes '
376-
'this method useless.',
377-
),
378-
ErrorHint(
379-
'You need to pass a non-null $AssetPathEntity or call this method '
380-
'when currentPathEntity is not null.',
381-
),
382-
]);
383-
}
384-
return true;
385-
}());
370+
assert(
371+
() {
372+
if (_currentPathEntity == null && pathEntity == null) {
373+
throw FlutterError.fromParts(<DiagnosticsNode>[
374+
ErrorSummary('Empty $AssetPathEntity was switched.'),
375+
ErrorDescription(
376+
'Neither currentPathEntity nor pathEntity is non-null, '
377+
'which makes this method useless.',
378+
),
379+
ErrorHint(
380+
'You need to pass a non-null $AssetPathEntity '
381+
'or call this method when currentPathEntity is not null.',
382+
),
383+
]);
384+
}
385+
return true;
386+
}(),
387+
);
386388
if (_currentPathEntity == null && pathEntity == null) {
387389
return;
388390
}

lib/src/widget/custom_checkbox.dart

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,17 +385,23 @@ class _CustomCheckboxState extends State<CustomCheckbox>
385385
break;
386386
case MaterialTapTargetSize.shrinkWrap:
387387
size = const Size(
388-
kMinInteractiveDimension - 8.0, kMinInteractiveDimension - 8.0);
388+
kMinInteractiveDimension - 8.0,
389+
kMinInteractiveDimension - 8.0,
390+
);
389391
break;
390392
}
391393
size += effectiveVisualDensity.baseSizeAdjustment;
392394
final BoxConstraints additionalConstraints = BoxConstraints.tight(size);
393395
final MouseCursor effectiveMouseCursor =
394396
MaterialStateProperty.resolveAs<MouseCursor?>(
395-
widget.mouseCursor, _states) ??
397+
widget.mouseCursor,
398+
_states,
399+
) ??
396400
themeData.checkboxTheme.mouseCursor?.resolve(_states) ??
397401
MaterialStateProperty.resolveAs<MouseCursor>(
398-
MaterialStateMouseCursor.clickable, _states);
402+
MaterialStateMouseCursor.clickable,
403+
_states,
404+
);
399405
// Colors need to be resolved in selected and non selected states separately
400406
// so that they can be lerped between.
401407
final Set<MaterialState> activeStates = _states
@@ -1285,12 +1291,23 @@ abstract class RenderToggleable extends RenderConstrainedBox {
12851291
@override
12861292
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
12871293
super.debugFillProperties(properties);
1288-
properties.add(FlagProperty('value',
1289-
value: value, ifTrue: 'checked', ifFalse: 'unchecked', showName: true));
1290-
properties.add(FlagProperty('isInteractive',
1294+
properties.add(
1295+
FlagProperty(
1296+
'value',
1297+
value: value,
1298+
ifTrue: 'checked',
1299+
ifFalse: 'unchecked',
1300+
showName: true,
1301+
),
1302+
);
1303+
properties.add(
1304+
FlagProperty(
1305+
'isInteractive',
12911306
value: isInteractive,
12921307
ifTrue: 'enabled',
12931308
ifFalse: 'disabled',
1294-
defaultValue: true));
1309+
defaultValue: true,
1310+
),
1311+
);
12951312
}
12961313
}

0 commit comments

Comments
 (0)