Skip to content

Commit

Permalink
Remove 'must be non-null' and 'must not be null' comments in widgets …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
gspencergoog authored Sep 20, 2023
1 parent 52969a0 commit 6e5134b
Show file tree
Hide file tree
Showing 85 changed files with 157 additions and 619 deletions.
14 changes: 0 additions & 14 deletions packages/flutter/lib/src/widgets/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,6 @@ abstract class Action<T extends Intent> with Diagnosticable {
@immutable
class ActionListener extends StatefulWidget {
/// Create a const [ActionListener].
///
/// The [listener], [action], and [child] arguments must not be null.
const ActionListener({
super.key,
required this.listener,
Expand All @@ -465,13 +463,9 @@ class ActionListener extends StatefulWidget {
});

/// The [ActionListenerCallback] callback to register with the [action].
///
/// Must not be null.
final ActionListenerCallback listener;

/// The [Action] that the callback will be registered with.
///
/// Must not be null.
final Action<Intent> action;

/// {@macro flutter.widgets.ProxyWidget.child}
Expand Down Expand Up @@ -712,8 +706,6 @@ class ActionDispatcher with Diagnosticable {
/// * [ActionDispatcher], the object that this widget uses to manage actions.
class Actions extends StatefulWidget {
/// Creates an [Actions] widget.
///
/// The [child], [actions], and [dispatcher] arguments must not be null.
const Actions({
super.key,
this.dispatcher,
Expand Down Expand Up @@ -950,8 +942,6 @@ class Actions extends StatefulWidget {
/// This method returns the result of invoking the action's [Action.invoke]
/// method.
///
/// The `context` and `intent` arguments must not be null.
///
/// If the given `intent` doesn't map to an action, then it will look to the
/// next ancestor [Actions] widget in the hierarchy until it reaches the root.
///
Expand Down Expand Up @@ -1003,8 +993,6 @@ class Actions extends StatefulWidget {
/// first action found was disabled, or the action itself returns null
/// from [Action.invoke], then this method returns null.
///
/// The `context` and `intent` arguments must not be null.
///
/// If the given `intent` doesn't map to an action, then it will look to the
/// next ancestor [Actions] widget in the hierarchy until it reaches the root.
/// If a suitable [Action] is found but its [Action.isEnabled] returns false,
Expand Down Expand Up @@ -1153,8 +1141,6 @@ class _ActionsScope extends InheritedWidget {
/// It hosts its own [FocusNode] or uses [focusNode], if given.
class FocusableActionDetector extends StatefulWidget {
/// Create a const [FocusableActionDetector].
///
/// The [enabled], [autofocus], [mouseCursor], and [child] arguments must not be null.
const FocusableActionDetector({
super.key,
this.enabled = true,
Expand Down
2 changes: 0 additions & 2 deletions packages/flutter/lib/src/widgets/animated_cross_fade.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ class AnimatedCrossFade extends StatefulWidget {
/// The [duration] of the animation is the same for all components (fade in,
/// fade out, and size), and you can pass [Interval]s instead of [Curve]s in
/// order to have finer control, e.g., creating an overlap between the fades.
///
/// All the arguments other than [key] must be non-null.
const AnimatedCrossFade({
super.key,
required this.firstChild,
Expand Down
4 changes: 1 addition & 3 deletions packages/flutter/lib/src/widgets/animated_size.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import 'ticker_provider.dart';
/// * [SizeTransition], which changes its size based on an [Animation].
class AnimatedSize extends StatefulWidget {
/// Creates a widget that animates its size to match that of its child.
///
/// The [curve] and [duration] arguments must not be null.
const AnimatedSize({
super.key,
this.child,
Expand Down Expand Up @@ -77,7 +75,7 @@ class AnimatedSize extends StatefulWidget {

/// {@macro flutter.material.Material.clipBehavior}
///
/// Defaults to [Clip.hardEdge], and must not be null.
/// Defaults to [Clip.hardEdge].
final Clip clipBehavior;

@override
Expand Down
3 changes: 0 additions & 3 deletions packages/flutter/lib/src/widgets/animated_switcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ typedef AnimatedSwitcherLayoutBuilder = Widget Function(Widget? currentChild, Li
/// * [FadeTransition], which [AnimatedSwitcher] uses to perform the transition.
class AnimatedSwitcher extends StatefulWidget {
/// Creates an [AnimatedSwitcher].
///
/// The [duration], [transitionBuilder], [layoutBuilder], [switchInCurve], and
/// [switchOutCurve] parameters must not be null.
const AnimatedSwitcher({
super.key,
this.child,
Expand Down
2 changes: 0 additions & 2 deletions packages/flutter/lib/src/widgets/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,6 @@ class WidgetsApp extends StatefulWidget {
/// Creates a widget that wraps a number of widgets that are commonly
/// required for an application.
///
/// The boolean arguments, [color], and [navigatorObservers] must not be null.
///
/// Most callers will want to use the [home] or [routes] parameters, or both.
/// The [home] parameter is a convenience for the following [routes] map:
///
Expand Down
4 changes: 0 additions & 4 deletions packages/flutter/lib/src/widgets/async.dart
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,6 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
/// strategy is given by [builder].
///
/// The [initialData] is used to create the initial snapshot.
///
/// The [builder] must not be null.
const StreamBuilder({
super.key,
this.initialData,
Expand Down Expand Up @@ -517,8 +515,6 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
class FutureBuilder<T> extends StatefulWidget {
/// Creates a widget that builds itself based on the latest snapshot of
/// interaction with a [Future].
///
/// The [builder] must not be null.
const FutureBuilder({
super.key,
required this.future,
Expand Down
2 changes: 0 additions & 2 deletions packages/flutter/lib/src/widgets/autofill.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ enum AutofillContextAction {
/// clean up actions to be run when a topmost [AutofillGroup] is disposed.
class AutofillGroup extends StatefulWidget {
/// Creates a scope for autofillable input fields.
///
/// The [child] argument must not be null.
const AutofillGroup({
super.key,
required this.child,
Expand Down
2 changes: 0 additions & 2 deletions packages/flutter/lib/src/widgets/automatic_keep_alive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,6 @@ class _AutomaticKeepAliveState extends State<AutomaticKeepAlive> {
/// [KeepAliveNotification] internally.
class KeepAliveNotification extends Notification {
/// Creates a notification to indicate that a subtree must be kept alive.
///
/// The [handle] must not be null.
const KeepAliveNotification(this.handle);

/// A [Listenable] that will inform its clients when the widget that fired the
Expand Down
5 changes: 0 additions & 5 deletions packages/flutter/lib/src/widgets/banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ enum BannerLocation {
/// Paints a [Banner].
class BannerPainter extends CustomPainter {
/// Creates a banner painter.
///
/// The [message], [textDirection], [location], and [layoutDirection]
/// arguments must not be null.
BannerPainter({
required this.message,
required this.textDirection,
Expand Down Expand Up @@ -236,8 +233,6 @@ class BannerPainter extends CustomPainter {
/// debug mode, to show a banner that says "DEBUG".
class Banner extends StatelessWidget {
/// Creates a banner.
///
/// The [message] and [location] arguments must not be null.
const Banner({
super.key,
this.child,
Expand Down
Loading

0 comments on commit 6e5134b

Please sign in to comment.