Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Enable sized_box_shrink_expand lint (#117371)
Browse files Browse the repository at this point in the history
* Enable  lint

* note about discarded_futures

* note about use_decorated_box

* update note on require_trailing_commas
  • Loading branch information
goderbauer authored Dec 20, 2022
1 parent 8289ea6 commit fa3777b
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 156 deletions.
10 changes: 5 additions & 5 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ linter:
- deprecated_consistency
# - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
- directives_ordering
# - discarded_futures # not yet tested
# - discarded_futures # too many false positives, similar to unawaited_futures
# - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
- empty_catches
- empty_constructor_bodies
Expand Down Expand Up @@ -170,7 +170,7 @@ linter:
- prefer_is_not_empty
- prefer_is_not_operator
- prefer_iterable_whereType
# - prefer_mixin # Has false positives, see https://github.com/dart-lang/linter/issues/3018
# - prefer_mixin # has false positives, see https://github.com/dart-lang/linter/issues/3018
# - prefer_null_aware_method_calls # "call()" is confusing to people new to the language since it's not documented anywhere
- prefer_null_aware_operators
- prefer_relative_imports
Expand All @@ -181,10 +181,10 @@ linter:
- provide_deprecation_message
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
- recursive_getters
# - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
# - require_trailing_commas # would be nice, but requires a lot of manual work: 10,000+ code locations would need to be reformatted by hand after bulk fix is applied
- secure_pubspec_urls
- sized_box_for_whitespace
# - sized_box_shrink_expand # not yet tested
- sized_box_shrink_expand
- slash_for_doc_comments
- sort_child_properties_last
- sort_constructors_first
Expand Down Expand Up @@ -222,7 +222,7 @@ linter:
- unsafe_html
- use_build_context_synchronously
# - use_colored_box # not yet tested
# - use_decorated_box # not yet tested
# - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding)
# - use_enums # not yet tested
- use_full_hex_values_for_flutter_colors
- use_function_type_syntax_for_parameters
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/cupertino/nav_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ class _BackLabel extends StatelessWidget {
// null here and unused.
Widget _buildPreviousTitleWidget(BuildContext context, String? previousTitle, Widget? child) {
if (previousTitle == null) {
return const SizedBox(height: 0.0, width: 0.0);
return const SizedBox.shrink();
}

Text textWidget = Text(
Expand Down Expand Up @@ -1602,7 +1602,7 @@ class _BackLabel extends StatelessWidget {
builder: _buildPreviousTitleWidget,
);
} else {
return const SizedBox(height: 0.0, width: 0.0);
return const SizedBox.shrink();
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions packages/flutter/lib/src/material/navigation_rail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -640,9 +640,7 @@ class _RailDestination extends StatelessWidget {
children: <Widget>[
iconPart,
// For semantics when label is not showing,
SizedBox(
width: 0,
height: 0,
SizedBox.shrink(
child: Visibility.maintain(
visible: false,
child: label,
Expand Down
4 changes: 1 addition & 3 deletions packages/flutter/test/material/app_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,7 @@ void main() {
await tester.pumpWidget(
MaterialApp(
home: Center(
child: SizedBox(
height: 0.0,
width: 0.0,
child: SizedBox.shrink(
child: Scaffold(
appBar: AppBar(
title: const Text('X'),
Expand Down
4 changes: 1 addition & 3 deletions packages/flutter/test/material/list_tile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1616,9 +1616,7 @@ void main() {

await tester.pumpWidget(const MaterialApp(
home: Scaffold(
body: SizedBox(
width: 0.0,
height: 0.0,
body: SizedBox.shrink(
child: ListTile(
key: key,
tileColor: Colors.green,
Expand Down
50 changes: 10 additions & 40 deletions packages/flutter/test/material/tooltip_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ void main() {
padding: const EdgeInsets.all(5.0),
verticalOffset: 20.0,
preferBelow: false,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -104,10 +101,7 @@ void main() {
padding: const EdgeInsets.all(5.0),
verticalOffset: 20.0,
preferBelow: false,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -164,10 +158,7 @@ void main() {
padding: const EdgeInsets.all(5.0),
verticalOffset: 20.0,
preferBelow: false,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -218,10 +209,7 @@ void main() {
padding: EdgeInsets.zero,
verticalOffset: 100.0,
preferBelow: false,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -274,10 +262,7 @@ void main() {
padding: EdgeInsets.zero,
verticalOffset: 100.0,
preferBelow: false,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -341,10 +326,7 @@ void main() {
padding: EdgeInsets.zero,
verticalOffset: 100.0,
preferBelow: true,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -396,10 +378,7 @@ void main() {
padding: EdgeInsets.zero,
verticalOffset: 10.0,
preferBelow: true,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -453,10 +432,7 @@ void main() {
padding: EdgeInsets.zero,
verticalOffset: 10.0,
preferBelow: true,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -559,10 +535,7 @@ void main() {
message: tooltipText,
padding: EdgeInsets.zero,
margin: const EdgeInsets.all(customMarginValue),
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
);
},
),
Expand Down Expand Up @@ -859,10 +832,7 @@ void main() {
key: tooltipKey,
decoration: customDecoration,
message: tooltipText,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
);
},
),
Expand Down
50 changes: 10 additions & 40 deletions packages/flutter/test/material/tooltip_theme_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -191,10 +188,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -251,10 +245,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -320,10 +311,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -391,10 +379,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -448,10 +433,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
),
],
Expand Down Expand Up @@ -500,10 +482,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
);
},
Expand Down Expand Up @@ -556,10 +535,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
),
);
},
Expand Down Expand Up @@ -715,10 +691,7 @@ void main() {
return Tooltip(
key: key,
message: tooltipText,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
);
},
),
Expand Down Expand Up @@ -755,10 +728,7 @@ void main() {
return Tooltip(
key: key,
message: tooltipText,
child: const SizedBox(
width: 0.0,
height: 0.0,
),
child: const SizedBox.shrink(),
);
},
),
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/rendering/paragraph_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ void main() {
test('assembleSemanticsNode handles empty WidgetSpans that do not yield selection boxes', () {
final TextSpan text = TextSpan(text: '', children: <InlineSpan>[
TextSpan(text: 'A', recognizer: TapGestureRecognizer()..onTap = () {}),
const WidgetSpan(child: SizedBox(width: 0, height: 0)),
const WidgetSpan(child: SizedBox.shrink()),
TextSpan(text: 'C', recognizer: TapGestureRecognizer()..onTap = () {}),
]);
final List<RenderBox> renderBoxes = <RenderBox>[
Expand Down
8 changes: 2 additions & 6 deletions packages/flutter/test/widgets/column_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ void main() {
const Key childKey = Key('childKey');

await tester.pumpWidget(Center(
child: SizedBox(
width: 0.0,
height: 0.0,
child: SizedBox.shrink(
child: Column(
mainAxisSize: MainAxisSize.min,
children: const <Widget>[
Expand Down Expand Up @@ -760,9 +758,7 @@ void main() {
const Key childKey = Key('childKey');

await tester.pumpWidget(Center(
child: SizedBox(
width: 0.0,
height: 0.0,
child: SizedBox.shrink(
child: Column(
mainAxisSize: MainAxisSize.min,
verticalDirection: VerticalDirection.up,
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/widgets/custom_paint_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void main() {
expect(target.currentContext!.size, const Size(800.0, 600.0));

await tester.pumpWidget(Center(
child: CustomPaint(key: target, child: const SizedBox(height: 0.0, width: 0.0)),
child: CustomPaint(key: target, child: const SizedBox.shrink()),
));
expect(target.currentContext!.size, Size.zero);

Expand Down
Loading

0 comments on commit fa3777b

Please sign in to comment.