Skip to content

Commit a1e49be

Browse files
authored
Remove 'must be non-null' and 'must not be null' comments from material. (flutter#134991)
## 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 material 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#134984 - flutter#134992 - flutter#134993 - flutter#134994 ## Tests - Documentation only change.
1 parent f4b5fc1 commit a1e49be

File tree

93 files changed

+127
-376
lines changed

Some content is hidden

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

93 files changed

+127
-376
lines changed

packages/flutter/lib/src/material/animated_icons/animated_icons.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ part of material_animated_icons; // ignore: use_string_in_part_of_directives
2929
class AnimatedIcon extends StatelessWidget {
3030
/// Creates an AnimatedIcon.
3131
///
32-
/// The [progress] and [icon] arguments must not be null.
33-
/// The [size] and [color] default to the value given by the current [IconTheme].
32+
/// The [size] and [color] default to the value given by the current
33+
/// [IconTheme].
3434
const AnimatedIcon({
3535
super.key,
3636
required this.icon,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ class MaterialApp extends StatefulWidget {
202202
/// unsupported route.
203203
///
204204
/// This class creates an instance of [WidgetsApp].
205-
///
206-
/// The boolean arguments, [routes], and [navigatorObservers], must not be null.
207205
const MaterialApp({
208206
super.key,
209207
this.navigatorKey,

packages/flutter/lib/src/material/app_bar.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,9 +1436,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
14361436
/// * <https://material.io/design/components/app-bars-top.html>
14371437
class SliverAppBar extends StatefulWidget {
14381438
/// Creates a Material Design app bar that can be placed in a [CustomScrollView].
1439-
///
1440-
/// The arguments [forceElevated], [primary], [floating], [pinned], [snap]
1441-
/// and [automaticallyImplyLeading] must not be null.
14421439
const SliverAppBar({
14431440
super.key,
14441441
this.leading,

packages/flutter/lib/src/material/app_bar_theme.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ class AppBarTheme with Diagnosticable {
200200

201201
/// Linearly interpolate between two AppBar themes.
202202
///
203-
/// The argument `t` must not be null.
204-
///
205203
/// {@macro dart.ui.shadow.lerp}
206204
static AppBarTheme lerp(AppBarTheme? a, AppBarTheme? b, double t) {
207205
if (identical(a, b) && a != null) {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ enum MaterialBannerClosedReason {
9393
class MaterialBanner extends StatefulWidget {
9494
/// Creates a [MaterialBanner].
9595
///
96-
/// The [actions], [content], and [forceActionsBelow] must be non-null.
97-
/// The [actions].length must be greater than 0. The [elevation] must be null or
98-
/// non-negative.
96+
/// The length of the [actions] list must not be empty. The [elevation] must
97+
/// be null or non-negative.
9998
const MaterialBanner({
10099
super.key,
101100
required this.content,

packages/flutter/lib/src/material/banner_theme.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ class MaterialBannerThemeData with Diagnosticable {
9797

9898
/// Linearly interpolate between two Banner themes.
9999
///
100-
/// The argument `t` must not be null.
101-
///
102100
/// {@macro dart.ui.shadow.lerp}
103101
static MaterialBannerThemeData lerp(MaterialBannerThemeData? a, MaterialBannerThemeData? b, double t) {
104102
return MaterialBannerThemeData(

packages/flutter/lib/src/material/bottom_app_bar_theme.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ class BottomAppBarTheme with Diagnosticable {
9494

9595
/// Linearly interpolate between two BAB themes.
9696
///
97-
/// The argument `t` must not be null.
98-
///
9997
/// {@macro dart.ui.shadow.lerp}
10098
static BottomAppBarTheme lerp(BottomAppBarTheme? a, BottomAppBarTheme? b, double t) {
10199
if (identical(a, b) && a != null) {

packages/flutter/lib/src/material/bottom_navigation_bar.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ enum BottomNavigationBarLandscapeLayout {
8080
/// [BottomNavigationBarType.fixed] when there are less than four items, and
8181
/// [BottomNavigationBarType.shifting] otherwise.
8282
///
83-
/// The length of [items] must be at least two and each item's icon and title/label
84-
/// must not be null.
83+
/// The length of [items] must be at least two and each item's icon and
84+
/// label must not be null.
8585
///
8686
/// * [BottomNavigationBarType.fixed], the default when there are less than
8787
/// four [items]. The selected item is rendered with the
@@ -188,7 +188,7 @@ class BottomNavigationBar extends StatefulWidget {
188188
/// are two or three [items], [BottomNavigationBarType.shifting] otherwise.
189189
///
190190
/// The [iconSize], [selectedFontSize], [unselectedFontSize], and [elevation]
191-
/// arguments must be non-null and non-negative.
191+
/// arguments must be non-negative.
192192
///
193193
/// If [selectedLabelStyle].color and [unselectedLabelStyle].color values
194194
/// are non-null, they will be used instead of [selectedItemColor] and

packages/flutter/lib/src/material/bottom_navigation_bar_theme.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ class BottomNavigationBarThemeData with Diagnosticable {
170170

171171
/// Linearly interpolate between two [BottomNavigationBarThemeData].
172172
///
173-
/// The argument `t` must not be null.
174-
///
175173
/// {@macro dart.ui.shadow.lerp}
176174
static BottomNavigationBarThemeData lerp(BottomNavigationBarThemeData? a, BottomNavigationBarThemeData? b, double t) {
177175
if (identical(a, b) && a != null) {
@@ -276,8 +274,6 @@ class BottomNavigationBarThemeData with Diagnosticable {
276274
class BottomNavigationBarTheme extends InheritedWidget {
277275
/// Constructs a bottom navigation bar theme that configures all descendant
278276
/// [BottomNavigationBar] widgets.
279-
///
280-
/// The [data] must not be null.
281277
const BottomNavigationBarTheme({
282278
super.key,
283279
required this.data,

packages/flutter/lib/src/material/bottom_sheet.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,8 +1133,6 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
11331133
/// curve specified with the [curve] argument, after the finger is released. In
11341134
/// such a case, the value of [startingPoint] would be the progress of the
11351135
/// animation at the time when the finger was released.
1136-
///
1137-
/// The [startingPoint] and [curve] arguments must not be null.
11381136
class _BottomSheetSuspendedCurve extends ParametricCurve<double> {
11391137
/// Creates a suspended curve.
11401138
const _BottomSheetSuspendedCurve(

0 commit comments

Comments
 (0)