Skip to content

Commit 6e5134b

Browse files
authored
Remove 'must be non-null' and 'must not be null' comments in widgets library (#134992)
## Description This removes all of the comments that are of the form "so-and-so (must not be null|can ?not be null|must be non-null)" from the cases where those values are defines as non-nullable values. This PR removes them from the widgets library. This was done by hand, since it really didn't lend itself to scripting, so it needs to be more than just spot-checked, I think. I was careful to leave any comment that referred to parameters that were nullable, but I may have missed some. In addition to being no longer relevant after null safety has been made the default, these comments were largely fragile, in that it was easy for them to get out of date, and not be accurate anymore anyhow. This did create a number of constructor comments which basically say "Creates a [Foo].", but I don't really know how to avoid that in a large scale change, since there's not much you can really say in a lot of cases. I think we might consider some leniency for constructors to the "Comment must be meaningful" style guidance (which we de facto have already, since there are a bunch of these). ## Related PRs - flutter/flutter#134984 - flutter/flutter#134991 - flutter/flutter#134993 - flutter/flutter#134994 ## Tests - Documentation only change.
1 parent 52969a0 commit 6e5134b

File tree

85 files changed

+157
-619
lines changed

Some content is hidden

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

85 files changed

+157
-619
lines changed

packages/flutter/lib/src/widgets/actions.dart

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,6 @@ abstract class Action<T extends Intent> with Diagnosticable {
455455
@immutable
456456
class ActionListener extends StatefulWidget {
457457
/// Create a const [ActionListener].
458-
///
459-
/// The [listener], [action], and [child] arguments must not be null.
460458
const ActionListener({
461459
super.key,
462460
required this.listener,
@@ -465,13 +463,9 @@ class ActionListener extends StatefulWidget {
465463
});
466464

467465
/// The [ActionListenerCallback] callback to register with the [action].
468-
///
469-
/// Must not be null.
470466
final ActionListenerCallback listener;
471467

472468
/// The [Action] that the callback will be registered with.
473-
///
474-
/// Must not be null.
475469
final Action<Intent> action;
476470

477471
/// {@macro flutter.widgets.ProxyWidget.child}
@@ -712,8 +706,6 @@ class ActionDispatcher with Diagnosticable {
712706
/// * [ActionDispatcher], the object that this widget uses to manage actions.
713707
class Actions extends StatefulWidget {
714708
/// Creates an [Actions] widget.
715-
///
716-
/// The [child], [actions], and [dispatcher] arguments must not be null.
717709
const Actions({
718710
super.key,
719711
this.dispatcher,
@@ -950,8 +942,6 @@ class Actions extends StatefulWidget {
950942
/// This method returns the result of invoking the action's [Action.invoke]
951943
/// method.
952944
///
953-
/// The `context` and `intent` arguments must not be null.
954-
///
955945
/// If the given `intent` doesn't map to an action, then it will look to the
956946
/// next ancestor [Actions] widget in the hierarchy until it reaches the root.
957947
///
@@ -1003,8 +993,6 @@ class Actions extends StatefulWidget {
1003993
/// first action found was disabled, or the action itself returns null
1004994
/// from [Action.invoke], then this method returns null.
1005995
///
1006-
/// The `context` and `intent` arguments must not be null.
1007-
///
1008996
/// If the given `intent` doesn't map to an action, then it will look to the
1009997
/// next ancestor [Actions] widget in the hierarchy until it reaches the root.
1010998
/// If a suitable [Action] is found but its [Action.isEnabled] returns false,
@@ -1153,8 +1141,6 @@ class _ActionsScope extends InheritedWidget {
11531141
/// It hosts its own [FocusNode] or uses [focusNode], if given.
11541142
class FocusableActionDetector extends StatefulWidget {
11551143
/// Create a const [FocusableActionDetector].
1156-
///
1157-
/// The [enabled], [autofocus], [mouseCursor], and [child] arguments must not be null.
11581144
const FocusableActionDetector({
11591145
super.key,
11601146
this.enabled = true,

packages/flutter/lib/src/widgets/animated_cross_fade.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ class AnimatedCrossFade extends StatefulWidget {
115115
/// The [duration] of the animation is the same for all components (fade in,
116116
/// fade out, and size), and you can pass [Interval]s instead of [Curve]s in
117117
/// order to have finer control, e.g., creating an overlap between the fades.
118-
///
119-
/// All the arguments other than [key] must be non-null.
120118
const AnimatedCrossFade({
121119
super.key,
122120
required this.firstChild,

packages/flutter/lib/src/widgets/animated_size.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import 'ticker_provider.dart';
2323
/// * [SizeTransition], which changes its size based on an [Animation].
2424
class AnimatedSize extends StatefulWidget {
2525
/// Creates a widget that animates its size to match that of its child.
26-
///
27-
/// The [curve] and [duration] arguments must not be null.
2826
const AnimatedSize({
2927
super.key,
3028
this.child,
@@ -77,7 +75,7 @@ class AnimatedSize extends StatefulWidget {
7775

7876
/// {@macro flutter.material.Material.clipBehavior}
7977
///
80-
/// Defaults to [Clip.hardEdge], and must not be null.
78+
/// Defaults to [Clip.hardEdge].
8179
final Clip clipBehavior;
8280

8381
@override

packages/flutter/lib/src/widgets/animated_switcher.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ typedef AnimatedSwitcherLayoutBuilder = Widget Function(Widget? currentChild, Li
103103
/// * [FadeTransition], which [AnimatedSwitcher] uses to perform the transition.
104104
class AnimatedSwitcher extends StatefulWidget {
105105
/// Creates an [AnimatedSwitcher].
106-
///
107-
/// The [duration], [transitionBuilder], [layoutBuilder], [switchInCurve], and
108-
/// [switchOutCurve] parameters must not be null.
109106
const AnimatedSwitcher({
110107
super.key,
111108
this.child,

packages/flutter/lib/src/widgets/app.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,6 @@ class WidgetsApp extends StatefulWidget {
264264
/// Creates a widget that wraps a number of widgets that are commonly
265265
/// required for an application.
266266
///
267-
/// The boolean arguments, [color], and [navigatorObservers] must not be null.
268-
///
269267
/// Most callers will want to use the [home] or [routes] parameters, or both.
270268
/// The [home] parameter is a convenience for the following [routes] map:
271269
///

packages/flutter/lib/src/widgets/async.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,6 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
386386
/// strategy is given by [builder].
387387
///
388388
/// The [initialData] is used to create the initial snapshot.
389-
///
390-
/// The [builder] must not be null.
391389
const StreamBuilder({
392390
super.key,
393391
this.initialData,
@@ -517,8 +515,6 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
517515
class FutureBuilder<T> extends StatefulWidget {
518516
/// Creates a widget that builds itself based on the latest snapshot of
519517
/// interaction with a [Future].
520-
///
521-
/// The [builder] must not be null.
522518
const FutureBuilder({
523519
super.key,
524520
required this.future,

packages/flutter/lib/src/widgets/autofill.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ enum AutofillContextAction {
6464
/// clean up actions to be run when a topmost [AutofillGroup] is disposed.
6565
class AutofillGroup extends StatefulWidget {
6666
/// Creates a scope for autofillable input fields.
67-
///
68-
/// The [child] argument must not be null.
6967
const AutofillGroup({
7068
super.key,
7169
required this.child,

packages/flutter/lib/src/widgets/automatic_keep_alive.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,6 @@ class _AutomaticKeepAliveState extends State<AutomaticKeepAlive> {
294294
/// [KeepAliveNotification] internally.
295295
class KeepAliveNotification extends Notification {
296296
/// Creates a notification to indicate that a subtree must be kept alive.
297-
///
298-
/// The [handle] must not be null.
299297
const KeepAliveNotification(this.handle);
300298

301299
/// A [Listenable] that will inform its clients when the widget that fired the

packages/flutter/lib/src/widgets/banner.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ enum BannerLocation {
5454
/// Paints a [Banner].
5555
class BannerPainter extends CustomPainter {
5656
/// Creates a banner painter.
57-
///
58-
/// The [message], [textDirection], [location], and [layoutDirection]
59-
/// arguments must not be null.
6057
BannerPainter({
6158
required this.message,
6259
required this.textDirection,
@@ -236,8 +233,6 @@ class BannerPainter extends CustomPainter {
236233
/// debug mode, to show a banner that says "DEBUG".
237234
class Banner extends StatelessWidget {
238235
/// Creates a banner.
239-
///
240-
/// The [message] and [location] arguments must not be null.
241236
const Banner({
242237
super.key,
243238
this.child,

0 commit comments

Comments
 (0)