Skip to content

Commit d248a65

Browse files
authored
Add flutter_lints to samples (#179091)
I recommend reviewing each commit individually. The following were suppressed instead of migrated to minimize the time the tree is closed: 1. The [`Radio` -> `RadioGroup` migration](https://docs.flutter.dev/release/breaking-changes/radio-api-redesign). Tracked by: #179088. Part of: #178827 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 7b98d50 commit d248a65

1,004 files changed

Lines changed: 13033 additions & 5930 deletions

File tree

Some content is hidden

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

engine/src/flutter/lib/ui/painting.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5519,10 +5519,10 @@ base class FragmentShader extends Shader {
55195519
/// shader.setFloat(2, 83); // uMagnitude y
55205520
///
55215521
/// // Convert color to premultiplied opacity.
5522-
/// shader.setFloat(3, color.red / 255 * color.opacity); // uColor r
5523-
/// shader.setFloat(4, color.green / 255 * color.opacity); // uColor g
5524-
/// shader.setFloat(5, color.blue / 255 * color.opacity); // uColor b
5525-
/// shader.setFloat(6, color.opacity); // uColor a
5522+
/// shader.setFloat(3, color.r * color.a); // uColor r
5523+
/// shader.setFloat(4, color.g * color.a); // uColor g
5524+
/// shader.setFloat(5, color.b * color.a); // uColor b
5525+
/// shader.setFloat(6, color.a); // uColor a
55265526
///
55275527
/// // initialize sampler uniform.
55285528
/// shader.setImageSampler(0, image);

examples/api/analysis_options.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
# This file is also used by dev/bots/analyze_snippet_code.dart to analyze code snippets (`{@tool snippet}` sections).
22

3-
# include: ../../analysis_options.yaml #TODO(Piinks): Replace with flutter_lints - separate change.
4-
5-
analyzer:
6-
errors:
7-
# We have some clean up to do here. Landing examples/api update separately.
8-
deprecated_member_use: ignore
3+
# The following line activates a set of recommended lints for Flutter apps,
4+
# packages, and plugins designed to encourage good coding practices.
5+
include: package:flutter_lints/flutter.yaml
96

107
linter:
118
rules:

examples/api/lib/animation/animation_controller/animated_digit.0.dart

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ class _PlaceholderDigit extends StatelessWidget {
2323
context,
2424
).textTheme.displayLarge!.copyWith(fontWeight: FontWeight.w500);
2525

26-
final Iterable<Widget> placeholderDigits = <int>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map<Widget>((
27-
int n,
28-
) {
29-
return Text('$n', style: textStyle);
30-
});
31-
32-
return Opacity(opacity: 0, child: Stack(children: placeholderDigits.toList()));
26+
final Iterable<Widget> placeholderDigits =
27+
<int>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map<Widget>((int n) {
28+
return Text('$n', style: textStyle);
29+
});
30+
31+
return Opacity(
32+
opacity: 0,
33+
child: Stack(children: placeholderDigits.toList()),
34+
);
3335
}
3436
}
3537

@@ -46,14 +48,15 @@ class AnimatedDigit extends StatefulWidget {
4648
State<AnimatedDigit> createState() => _AnimatedDigitState();
4749
}
4850

49-
class _AnimatedDigitState extends State<AnimatedDigit> with SingleTickerProviderStateMixin {
51+
class _AnimatedDigitState extends State<AnimatedDigit>
52+
with SingleTickerProviderStateMixin {
5053
static const Duration defaultDuration = Duration(milliseconds: 300);
5154

5255
late final AnimationController controller;
5356
late int incomingValue;
5457
late int outgoingValue;
55-
List<int> pendingValues =
56-
<int>[]; // widget.value updates that occurred while the animation is underway
58+
// widget.value updates that occurred while the animation is underway.
59+
List<int> pendingValues = <int>[];
5760
Duration duration = defaultDuration;
5861

5962
@override
@@ -109,7 +112,8 @@ class _AnimatedDigitState extends State<AnimatedDigit> with SingleTickerProvider
109112
// will show the pending values.
110113
pendingValues.add(widget.value);
111114
final double percentRemaining = 1 - controller.value;
112-
duration = defaultDuration * (1 / (percentRemaining + pendingValues.length));
115+
duration =
116+
defaultDuration * (1 / (percentRemaining + pendingValues.length));
113117
controller.animateTo(1.0, duration: duration * percentRemaining);
114118
} else {
115119
animateValueUpdate(incomingValue, widget.value);
@@ -134,7 +138,11 @@ class _AnimatedDigitState extends State<AnimatedDigit> with SingleTickerProvider
134138
end: const Offset(0, -1), // Out of view above the top.
135139
),
136140
),
137-
child: Text(key: ValueKey<int>(outgoingValue), '$outgoingValue', style: textStyle),
141+
child: Text(
142+
key: ValueKey<int>(outgoingValue),
143+
'$outgoingValue',
144+
style: textStyle,
145+
),
138146
),
139147
SlideTransition(
140148
position: controller.drive(
@@ -143,7 +151,11 @@ class _AnimatedDigitState extends State<AnimatedDigit> with SingleTickerProvider
143151
end: Offset.zero,
144152
),
145153
),
146-
child: Text(key: ValueKey<int>(incomingValue), '$incomingValue', style: textStyle),
154+
child: Text(
155+
key: ValueKey<int>(incomingValue),
156+
'$incomingValue',
157+
style: textStyle,
158+
),
147159
),
148160
],
149161
),

examples/api/lib/animation/curves/curve2_d.0.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ class FollowCurve2D extends StatefulWidget {
5454
State<FollowCurve2D> createState() => _FollowCurve2DState();
5555
}
5656

57-
class _FollowCurve2DState extends State<FollowCurve2D> with TickerProviderStateMixin {
57+
class _FollowCurve2DState extends State<FollowCurve2D>
58+
with TickerProviderStateMixin {
5859
// The animation controller for this animation.
5960
late AnimationController controller;
6061
// The animation that will be used to apply the widget's animation curve.
@@ -81,8 +82,12 @@ class _FollowCurve2DState extends State<FollowCurve2D> with TickerProviderStateM
8182
@override
8283
Widget build(BuildContext context) {
8384
// Scale the path values to match the -1.0 to 1.0 domain of the Alignment widget.
84-
final Offset position = widget.path.transform(animation.value) * 2.0 - const Offset(1.0, 1.0);
85-
return Align(alignment: Alignment(position.dx, position.dy), child: widget.child);
85+
final Offset position =
86+
widget.path.transform(animation.value) * 2.0 - const Offset(1.0, 1.0);
87+
return Align(
88+
alignment: Alignment(position.dx, position.dy),
89+
child: widget.child,
90+
);
8691
}
8792
}
8893

examples/api/lib/cupertino/activity_indicator/cupertino_activity_indicator.0.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ class CupertinoIndicatorExample extends StatelessWidget {
2626
@override
2727
Widget build(BuildContext context) {
2828
return const CupertinoPageScaffold(
29-
navigationBar: CupertinoNavigationBar(middle: Text('CupertinoActivityIndicator Sample')),
29+
navigationBar: CupertinoNavigationBar(
30+
middle: Text('CupertinoActivityIndicator Sample'),
31+
),
3032
child: Center(
3133
child: Column(
3234
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
@@ -44,7 +46,10 @@ class CupertinoIndicatorExample extends StatelessWidget {
4446
mainAxisAlignment: MainAxisAlignment.center,
4547
children: <Widget>[
4648
// Cupertino activity indicator with custom radius and color.
47-
CupertinoActivityIndicator(radius: 20.0, color: CupertinoColors.activeBlue),
49+
CupertinoActivityIndicator(
50+
radius: 20.0,
51+
color: CupertinoColors.activeBlue,
52+
),
4853
SizedBox(height: 10),
4954
Text(
5055
'radius: 20.0\ncolor: CupertinoColors.activeBlue',
@@ -59,7 +64,10 @@ class CupertinoIndicatorExample extends StatelessWidget {
5964
// animation.
6065
CupertinoActivityIndicator(radius: 20.0, animating: false),
6166
SizedBox(height: 10),
62-
Text('radius: 20.0\nanimating: false', textAlign: TextAlign.center),
67+
Text(
68+
'radius: 20.0\nanimating: false',
69+
textAlign: TextAlign.center,
70+
),
6371
],
6472
),
6573
],

examples/api/lib/cupertino/activity_indicator/cupertino_linear_activity_indicator.0.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ class CupertinoIndicatorExample extends StatelessWidget {
6161
Column(
6262
mainAxisAlignment: MainAxisAlignment.center,
6363
children: <Widget>[
64-
CupertinoLinearActivityIndicator(progress: 0.6, color: CupertinoColors.activeGreen),
64+
CupertinoLinearActivityIndicator(
65+
progress: 0.6,
66+
color: CupertinoColors.activeGreen,
67+
),
6568
SizedBox(height: 10),
6669
Text('Color: green', textAlign: TextAlign.center),
6770
],

examples/api/lib/cupertino/bottom_tab_bar/cupertino_tab_bar.0.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,22 @@ class CupertinoTabBarExample extends StatelessWidget {
2828
return CupertinoTabScaffold(
2929
tabBar: CupertinoTabBar(
3030
items: const <BottomNavigationBarItem>[
31-
BottomNavigationBarItem(icon: Icon(CupertinoIcons.star_fill), label: 'Favorites'),
32-
BottomNavigationBarItem(icon: Icon(CupertinoIcons.clock_solid), label: 'Recents'),
31+
BottomNavigationBarItem(
32+
icon: Icon(CupertinoIcons.star_fill),
33+
label: 'Favorites',
34+
),
35+
BottomNavigationBarItem(
36+
icon: Icon(CupertinoIcons.clock_solid),
37+
label: 'Recents',
38+
),
3339
BottomNavigationBarItem(
3440
icon: Icon(CupertinoIcons.person_alt_circle_fill),
3541
label: 'Contacts',
3642
),
37-
BottomNavigationBarItem(icon: Icon(CupertinoIcons.circle_grid_3x3_fill), label: 'Keypad'),
43+
BottomNavigationBarItem(
44+
icon: Icon(CupertinoIcons.circle_grid_3x3_fill),
45+
label: 'Keypad',
46+
),
3847
],
3948
),
4049
tabBuilder: (BuildContext context, int index) {

examples/api/lib/cupertino/button/cupertino_button.0.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,26 @@ class CupertinoButtonExample extends StatelessWidget {
2626
@override
2727
Widget build(BuildContext context) {
2828
return CupertinoPageScaffold(
29-
navigationBar: const CupertinoNavigationBar(middle: Text('CupertinoButton Sample')),
29+
navigationBar: const CupertinoNavigationBar(
30+
middle: Text('CupertinoButton Sample'),
31+
),
3032
child: Center(
3133
child: Column(
3234
mainAxisSize: MainAxisSize.min,
3335
children: <Widget>[
3436
const CupertinoButton(onPressed: null, child: Text('Disabled')),
3537
const SizedBox(height: 30),
36-
const CupertinoButton.filled(onPressed: null, child: Text('Disabled')),
38+
const CupertinoButton.filled(
39+
onPressed: null,
40+
child: Text('Disabled'),
41+
),
3742
const SizedBox(height: 30),
3843
CupertinoButton(onPressed: () {}, child: const Text('Enabled')),
3944
const SizedBox(height: 30),
40-
CupertinoButton.filled(onPressed: () {}, child: const Text('Enabled')),
45+
CupertinoButton.filled(
46+
onPressed: () {},
47+
child: const Text('Enabled'),
48+
),
4149
],
4250
),
4351
),

examples/api/lib/cupertino/checkbox/cupertino_checkbox.0.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ class CupertinoCheckboxApp extends StatelessWidget {
1616
return const CupertinoApp(
1717
theme: CupertinoThemeData(brightness: Brightness.light),
1818
home: CupertinoPageScaffold(
19-
navigationBar: CupertinoNavigationBar(middle: Text('CupertinoCheckbox Example')),
19+
navigationBar: CupertinoNavigationBar(
20+
middle: Text('CupertinoCheckbox Example'),
21+
),
2022
child: SafeArea(child: CupertinoCheckboxExample()),
2123
),
2224
);
@@ -27,7 +29,8 @@ class CupertinoCheckboxExample extends StatefulWidget {
2729
const CupertinoCheckboxExample({super.key});
2830

2931
@override
30-
State<CupertinoCheckboxExample> createState() => _CupertinoCheckboxExampleState();
32+
State<CupertinoCheckboxExample> createState() =>
33+
_CupertinoCheckboxExampleState();
3134
}
3235

3336
class _CupertinoCheckboxExampleState extends State<CupertinoCheckboxExample> {

examples/api/lib/cupertino/context_menu/cupertino_context_menu.0.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ class ContextMenuExample extends StatelessWidget {
2626
@override
2727
Widget build(BuildContext context) {
2828
return CupertinoPageScaffold(
29-
navigationBar: const CupertinoNavigationBar(middle: Text('CupertinoContextMenu Sample')),
29+
navigationBar: const CupertinoNavigationBar(
30+
middle: Text('CupertinoContextMenu Sample'),
31+
),
3032
child: Center(
3133
child: SizedBox(
3234
width: 100,

0 commit comments

Comments
 (0)