Skip to content

Commit 4ce7fdd

Browse files
authored
Remove 'must be non-null' and 'must not be null' comments from non-framework libraries (flutter#134994)
## Description This removes all of the comments that are of the form "so-and-so must not be null" or "so-and-so must be non-null" from the cases where those values are defines as non-nullable values. This PR removes them from the library in the repo that don't have anything to do with the framework. 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#134991 - flutter#134992 - flutter#134993 ## Tests - Documentation only change.
1 parent d3c6056 commit 4ce7fdd

File tree

12 files changed

+7
-60
lines changed

12 files changed

+7
-60
lines changed

dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ Future<void> _dummyAsyncVoidCallback() async {}
8383
@sealed
8484
class Runner {
8585
/// Creates a runner for the [recorder].
86-
///
87-
/// All arguments must not be null.
8886
Runner({
8987
required this.recorder,
9088
this.setUpAllDidRun = _dummyAsyncVoidCallback,

dev/tools/gen_keycodes/lib/physical_key_data.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ class PhysicalKeyData {
214214
/// written with the [toJson] method.
215215
class PhysicalKeyEntry {
216216
/// Creates a single key entry from available data.
217-
///
218-
/// The [usbHidCode] and [chromiumName] parameters must not be null.
219217
PhysicalKeyEntry({
220218
required this.usbHidCode,
221219
required this.name,

examples/layers/rendering/src/sector_layout.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,6 @@ class SectorHitTestResult extends HitTestResult {
636636
/// A hit test entry used by [RenderSector].
637637
class SectorHitTestEntry extends HitTestEntry {
638638
/// Creates a box hit test entry.
639-
///
640-
/// The [radius] and [theta] argument must not be null.
641639
SectorHitTestEntry(RenderSector super.target, { required this.radius, required this.theta });
642640

643641
@override

packages/flutter_driver/lib/src/common/wait.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import 'message.dart';
99
/// A Flutter Driver command that waits until a given [condition] is satisfied.
1010
class WaitForCondition extends Command {
1111
/// Creates a command that waits for the given [condition] is met.
12-
///
13-
/// The [condition] argument must not be null.
1412
const WaitForCondition(this.condition, {super.timeout});
1513

1614
/// Deserializes this command from the value generated by [serialize].
@@ -89,8 +87,6 @@ class NoTransientCallbacks extends SerializableWaitCondition {
8987

9088
/// Factory constructor to parse a [NoTransientCallbacks] instance from the
9189
/// given JSON map.
92-
///
93-
/// The [json] argument must not be null.
9490
factory NoTransientCallbacks.deserialize(Map<String, String> json) {
9591
if (json['conditionName'] != 'NoTransientCallbacksCondition') {
9692
throw SerializationException('Error occurred during deserializing the NoTransientCallbacksCondition JSON string: $json');
@@ -109,8 +105,6 @@ class NoPendingFrame extends SerializableWaitCondition {
109105

110106
/// Factory constructor to parse a [NoPendingFrame] instance from the given
111107
/// JSON map.
112-
///
113-
/// The [json] argument must not be null.
114108
factory NoPendingFrame.deserialize(Map<String, String> json) {
115109
if (json['conditionName'] != 'NoPendingFrameCondition') {
116110
throw SerializationException('Error occurred during deserializing the NoPendingFrameCondition JSON string: $json');
@@ -129,8 +123,6 @@ class FirstFrameRasterized extends SerializableWaitCondition {
129123

130124
/// Factory constructor to parse a [FirstFrameRasterized] instance from the
131125
/// given JSON map.
132-
///
133-
/// The [json] argument must not be null.
134126
factory FirstFrameRasterized.deserialize(Map<String, String> json) {
135127
if (json['conditionName'] != 'FirstFrameRasterizedCondition') {
136128
throw SerializationException('Error occurred during deserializing the FirstFrameRasterizedCondition JSON string: $json');
@@ -152,8 +144,6 @@ class NoPendingPlatformMessages extends SerializableWaitCondition {
152144

153145
/// Factory constructor to parse a [NoPendingPlatformMessages] instance from the
154146
/// given JSON map.
155-
///
156-
/// The [json] argument must not be null.
157147
factory NoPendingPlatformMessages.deserialize(Map<String, String> json) {
158148
if (json['conditionName'] != 'NoPendingPlatformMessagesCondition') {
159149
throw SerializationException('Error occurred during deserializing the NoPendingPlatformMessagesCondition JSON string: $json');
@@ -168,14 +158,10 @@ class NoPendingPlatformMessages extends SerializableWaitCondition {
168158
/// A combined condition that waits until all the given [conditions] are met.
169159
class CombinedCondition extends SerializableWaitCondition {
170160
/// Creates a [CombinedCondition] condition.
171-
///
172-
/// The [conditions] argument must not be null.
173161
const CombinedCondition(this.conditions);
174162

175163
/// Factory constructor to parse a [CombinedCondition] instance from the
176164
/// given JSON map.
177-
///
178-
/// The [jsonMap] argument must not be null.
179165
factory CombinedCondition.deserialize(Map<String, String> jsonMap) {
180166
if (jsonMap['conditionName'] != 'CombinedCondition') {
181167
throw SerializationException('Error occurred during deserializing the CombinedCondition JSON string: $jsonMap');
@@ -210,8 +196,6 @@ class CombinedCondition extends SerializableWaitCondition {
210196
}
211197

212198
/// Parses a [SerializableWaitCondition] or its subclass from the given [json] map.
213-
///
214-
/// The [json] argument must not be null.
215199
SerializableWaitCondition _deserialize(Map<String, String> json) {
216200
final String conditionName = json['conditionName']!;
217201
switch (conditionName) {

packages/flutter_driver/lib/src/extension/wait_conditions.dart

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ class _InternalNoTransientCallbacksCondition implements WaitCondition {
3939

4040
/// Factory constructor to parse an [InternalNoTransientCallbacksCondition]
4141
/// instance from the given [SerializableWaitCondition] instance.
42-
///
43-
/// The [condition] argument must not be null.
4442
factory _InternalNoTransientCallbacksCondition.deserialize(SerializableWaitCondition condition) {
4543
if (condition.conditionName != 'NoTransientCallbacksCondition') {
4644
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
@@ -67,8 +65,6 @@ class _InternalNoPendingFrameCondition implements WaitCondition {
6765

6866
/// Factory constructor to parse an [InternalNoPendingFrameCondition] instance
6967
/// from the given [SerializableWaitCondition] instance.
70-
///
71-
/// The [condition] argument must not be null.
7268
factory _InternalNoPendingFrameCondition.deserialize(SerializableWaitCondition condition) {
7369
if (condition.conditionName != 'NoPendingFrameCondition') {
7470
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
@@ -95,8 +91,6 @@ class _InternalFirstFrameRasterizedCondition implements WaitCondition {
9591

9692
/// Factory constructor to parse an [InternalNoPendingFrameCondition] instance
9793
/// from the given [SerializableWaitCondition] instance.
98-
///
99-
/// The [condition] argument must not be null.
10094
factory _InternalFirstFrameRasterizedCondition.deserialize(SerializableWaitCondition condition) {
10195
if (condition.conditionName != 'FirstFrameRasterizedCondition') {
10296
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
@@ -121,8 +115,6 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition {
121115

122116
/// Factory constructor to parse an [_InternalNoPendingPlatformMessagesCondition] instance
123117
/// from the given [SerializableWaitCondition] instance.
124-
///
125-
/// The [condition] argument must not be null.
126118
factory _InternalNoPendingPlatformMessagesCondition.deserialize(SerializableWaitCondition condition) {
127119
if (condition.conditionName != 'NoPendingPlatformMessagesCondition') {
128120
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
@@ -150,14 +142,10 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition {
150142
class _InternalCombinedCondition implements WaitCondition {
151143
/// Creates an [_InternalCombinedCondition] instance with the given list of
152144
/// [conditions].
153-
///
154-
/// The [conditions] argument must not be null.
155145
const _InternalCombinedCondition(this.conditions);
156146

157147
/// Factory constructor to parse an [_InternalCombinedCondition] instance from
158148
/// the given [SerializableWaitCondition] instance.
159-
///
160-
/// The [condition] argument must not be null.
161149
factory _InternalCombinedCondition.deserialize(SerializableWaitCondition condition) {
162150
if (condition.conditionName != 'CombinedCondition') {
163151
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
@@ -187,8 +175,6 @@ class _InternalCombinedCondition implements WaitCondition {
187175
}
188176

189177
/// Parses a [WaitCondition] or its subclass from the given serializable [waitCondition].
190-
///
191-
/// The [waitCondition] argument must not be null.
192178
WaitCondition deserializeCondition(SerializableWaitCondition waitCondition) {
193179
final String conditionName = waitCondition.conditionName;
194180
switch (conditionName) {

packages/flutter_test/lib/src/animation_sheet.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ class AnimationSheetBuilder {
175175
/// [collate]. If neither condition is met, the frames are not recorded, which
176176
/// is useful during setup phases.
177177
///
178-
/// The `child` must not be null.
179-
///
180178
/// See also:
181179
///
182180
/// * [WidgetTester.pumpFrames], which renders a widget in a series of frames

packages/flutter_test/lib/src/binding.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
782782
///
783783
/// The `description` is used by the [LiveTestWidgetsFlutterBinding] to
784784
/// show a label on the screen during the test. The description comes from
785-
/// the value passed to [testWidgets]. It must not be null.
785+
/// the value passed to [testWidgets].
786786
Future<void> runTest(
787787
Future<void> Function() testBody,
788788
VoidCallback invariantTester, {

packages/flutter_test/lib/src/controller.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ abstract class WidgetController {
14261426
/// Specify `platform` as one of the platforms allowed in
14271427
/// [platform.Platform.operatingSystem] to make the event appear to be from
14281428
/// that type of system. Defaults to "web" on web, and "android" everywhere
1429-
/// else. Must not be null.
1429+
/// else.
14301430
///
14311431
/// Specify the `physicalKey` for the event to override what is included in
14321432
/// the simulated event. If not specified, it uses a default from the US
@@ -1471,7 +1471,7 @@ abstract class WidgetController {
14711471
/// Specify `platform` as one of the platforms allowed in
14721472
/// [platform.Platform.operatingSystem] to make the event appear to be from
14731473
/// that type of system. Defaults to "web" on web, and "android" everywhere
1474-
/// else. Must not be null.
1474+
/// else.
14751475
///
14761476
/// Specify the `physicalKey` for the event to override what is included in
14771477
/// the simulated event. If not specified, it uses a default from the US

packages/flutter_test/lib/src/test_default_binary_messenger.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ typedef AllMessagesHandler = Future<ByteData?>? Function(
4747
/// Listeners for these messages are configured using [setMessageHandler].
4848
class TestDefaultBinaryMessenger extends BinaryMessenger {
4949
/// Creates a [TestDefaultBinaryMessenger] instance.
50-
///
51-
/// The [delegate] instance must not be null.
5250
TestDefaultBinaryMessenger(
5351
this.delegate, {
5452
Map<String, MessageHandler> outboundHandlers = const <String, MessageHandler>{},

packages/flutter_tools/lib/src/build_system/targets/icon_tree_shaker.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ List<Map<String, Object?>> _getList(Object? object, String errorMessage) {
2828
class IconTreeShaker {
2929
/// Creates a wrapper for icon font subsetting.
3030
///
31-
/// The environment parameter must not be null.
32-
///
3331
/// If the `fontManifest` parameter is null, [enabled] will return false since
3432
/// there are no fonts to shake.
3533
///

0 commit comments

Comments
 (0)