Unverified Commit 4ce7fdd9 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Remove 'must be non-null' and 'must not be null' comments from non-framework libraries (#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
- https://github.com/flutter/flutter/pull/134984
- https://github.com/flutter/flutter/pull/134991
- https://github.com/flutter/flutter/pull/134992
- https://github.com/flutter/flutter/pull/134993

## Tests
 - Documentation only change.
parent d3c60569
...@@ -83,8 +83,6 @@ Future<void> _dummyAsyncVoidCallback() async {} ...@@ -83,8 +83,6 @@ Future<void> _dummyAsyncVoidCallback() async {}
@sealed @sealed
class Runner { class Runner {
/// Creates a runner for the [recorder]. /// Creates a runner for the [recorder].
///
/// All arguments must not be null.
Runner({ Runner({
required this.recorder, required this.recorder,
this.setUpAllDidRun = _dummyAsyncVoidCallback, this.setUpAllDidRun = _dummyAsyncVoidCallback,
......
...@@ -214,8 +214,6 @@ class PhysicalKeyData { ...@@ -214,8 +214,6 @@ class PhysicalKeyData {
/// written with the [toJson] method. /// written with the [toJson] method.
class PhysicalKeyEntry { class PhysicalKeyEntry {
/// Creates a single key entry from available data. /// Creates a single key entry from available data.
///
/// The [usbHidCode] and [chromiumName] parameters must not be null.
PhysicalKeyEntry({ PhysicalKeyEntry({
required this.usbHidCode, required this.usbHidCode,
required this.name, required this.name,
......
...@@ -636,8 +636,6 @@ class SectorHitTestResult extends HitTestResult { ...@@ -636,8 +636,6 @@ class SectorHitTestResult extends HitTestResult {
/// A hit test entry used by [RenderSector]. /// A hit test entry used by [RenderSector].
class SectorHitTestEntry extends HitTestEntry { class SectorHitTestEntry extends HitTestEntry {
/// Creates a box hit test entry. /// Creates a box hit test entry.
///
/// The [radius] and [theta] argument must not be null.
SectorHitTestEntry(RenderSector super.target, { required this.radius, required this.theta }); SectorHitTestEntry(RenderSector super.target, { required this.radius, required this.theta });
@override @override
......
...@@ -9,8 +9,6 @@ import 'message.dart'; ...@@ -9,8 +9,6 @@ import 'message.dart';
/// A Flutter Driver command that waits until a given [condition] is satisfied. /// A Flutter Driver command that waits until a given [condition] is satisfied.
class WaitForCondition extends Command { class WaitForCondition extends Command {
/// Creates a command that waits for the given [condition] is met. /// Creates a command that waits for the given [condition] is met.
///
/// The [condition] argument must not be null.
const WaitForCondition(this.condition, {super.timeout}); const WaitForCondition(this.condition, {super.timeout});
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
...@@ -89,8 +87,6 @@ class NoTransientCallbacks extends SerializableWaitCondition { ...@@ -89,8 +87,6 @@ class NoTransientCallbacks extends SerializableWaitCondition {
/// Factory constructor to parse a [NoTransientCallbacks] instance from the /// Factory constructor to parse a [NoTransientCallbacks] instance from the
/// given JSON map. /// given JSON map.
///
/// The [json] argument must not be null.
factory NoTransientCallbacks.deserialize(Map<String, String> json) { factory NoTransientCallbacks.deserialize(Map<String, String> json) {
if (json['conditionName'] != 'NoTransientCallbacksCondition') { if (json['conditionName'] != 'NoTransientCallbacksCondition') {
throw SerializationException('Error occurred during deserializing the NoTransientCallbacksCondition JSON string: $json'); throw SerializationException('Error occurred during deserializing the NoTransientCallbacksCondition JSON string: $json');
...@@ -109,8 +105,6 @@ class NoPendingFrame extends SerializableWaitCondition { ...@@ -109,8 +105,6 @@ class NoPendingFrame extends SerializableWaitCondition {
/// Factory constructor to parse a [NoPendingFrame] instance from the given /// Factory constructor to parse a [NoPendingFrame] instance from the given
/// JSON map. /// JSON map.
///
/// The [json] argument must not be null.
factory NoPendingFrame.deserialize(Map<String, String> json) { factory NoPendingFrame.deserialize(Map<String, String> json) {
if (json['conditionName'] != 'NoPendingFrameCondition') { if (json['conditionName'] != 'NoPendingFrameCondition') {
throw SerializationException('Error occurred during deserializing the NoPendingFrameCondition JSON string: $json'); throw SerializationException('Error occurred during deserializing the NoPendingFrameCondition JSON string: $json');
...@@ -129,8 +123,6 @@ class FirstFrameRasterized extends SerializableWaitCondition { ...@@ -129,8 +123,6 @@ class FirstFrameRasterized extends SerializableWaitCondition {
/// Factory constructor to parse a [FirstFrameRasterized] instance from the /// Factory constructor to parse a [FirstFrameRasterized] instance from the
/// given JSON map. /// given JSON map.
///
/// The [json] argument must not be null.
factory FirstFrameRasterized.deserialize(Map<String, String> json) { factory FirstFrameRasterized.deserialize(Map<String, String> json) {
if (json['conditionName'] != 'FirstFrameRasterizedCondition') { if (json['conditionName'] != 'FirstFrameRasterizedCondition') {
throw SerializationException('Error occurred during deserializing the FirstFrameRasterizedCondition JSON string: $json'); throw SerializationException('Error occurred during deserializing the FirstFrameRasterizedCondition JSON string: $json');
...@@ -152,8 +144,6 @@ class NoPendingPlatformMessages extends SerializableWaitCondition { ...@@ -152,8 +144,6 @@ class NoPendingPlatformMessages extends SerializableWaitCondition {
/// Factory constructor to parse a [NoPendingPlatformMessages] instance from the /// Factory constructor to parse a [NoPendingPlatformMessages] instance from the
/// given JSON map. /// given JSON map.
///
/// The [json] argument must not be null.
factory NoPendingPlatformMessages.deserialize(Map<String, String> json) { factory NoPendingPlatformMessages.deserialize(Map<String, String> json) {
if (json['conditionName'] != 'NoPendingPlatformMessagesCondition') { if (json['conditionName'] != 'NoPendingPlatformMessagesCondition') {
throw SerializationException('Error occurred during deserializing the NoPendingPlatformMessagesCondition JSON string: $json'); throw SerializationException('Error occurred during deserializing the NoPendingPlatformMessagesCondition JSON string: $json');
...@@ -168,14 +158,10 @@ class NoPendingPlatformMessages extends SerializableWaitCondition { ...@@ -168,14 +158,10 @@ class NoPendingPlatformMessages extends SerializableWaitCondition {
/// A combined condition that waits until all the given [conditions] are met. /// A combined condition that waits until all the given [conditions] are met.
class CombinedCondition extends SerializableWaitCondition { class CombinedCondition extends SerializableWaitCondition {
/// Creates a [CombinedCondition] condition. /// Creates a [CombinedCondition] condition.
///
/// The [conditions] argument must not be null.
const CombinedCondition(this.conditions); const CombinedCondition(this.conditions);
/// Factory constructor to parse a [CombinedCondition] instance from the /// Factory constructor to parse a [CombinedCondition] instance from the
/// given JSON map. /// given JSON map.
///
/// The [jsonMap] argument must not be null.
factory CombinedCondition.deserialize(Map<String, String> jsonMap) { factory CombinedCondition.deserialize(Map<String, String> jsonMap) {
if (jsonMap['conditionName'] != 'CombinedCondition') { if (jsonMap['conditionName'] != 'CombinedCondition') {
throw SerializationException('Error occurred during deserializing the CombinedCondition JSON string: $jsonMap'); throw SerializationException('Error occurred during deserializing the CombinedCondition JSON string: $jsonMap');
...@@ -210,8 +196,6 @@ class CombinedCondition extends SerializableWaitCondition { ...@@ -210,8 +196,6 @@ class CombinedCondition extends SerializableWaitCondition {
} }
/// Parses a [SerializableWaitCondition] or its subclass from the given [json] map. /// Parses a [SerializableWaitCondition] or its subclass from the given [json] map.
///
/// The [json] argument must not be null.
SerializableWaitCondition _deserialize(Map<String, String> json) { SerializableWaitCondition _deserialize(Map<String, String> json) {
final String conditionName = json['conditionName']!; final String conditionName = json['conditionName']!;
switch (conditionName) { switch (conditionName) {
......
...@@ -39,8 +39,6 @@ class _InternalNoTransientCallbacksCondition implements WaitCondition { ...@@ -39,8 +39,6 @@ class _InternalNoTransientCallbacksCondition implements WaitCondition {
/// Factory constructor to parse an [InternalNoTransientCallbacksCondition] /// Factory constructor to parse an [InternalNoTransientCallbacksCondition]
/// instance from the given [SerializableWaitCondition] instance. /// instance from the given [SerializableWaitCondition] instance.
///
/// The [condition] argument must not be null.
factory _InternalNoTransientCallbacksCondition.deserialize(SerializableWaitCondition condition) { factory _InternalNoTransientCallbacksCondition.deserialize(SerializableWaitCondition condition) {
if (condition.conditionName != 'NoTransientCallbacksCondition') { if (condition.conditionName != 'NoTransientCallbacksCondition') {
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}'); throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
...@@ -67,8 +65,6 @@ class _InternalNoPendingFrameCondition implements WaitCondition { ...@@ -67,8 +65,6 @@ class _InternalNoPendingFrameCondition implements WaitCondition {
/// Factory constructor to parse an [InternalNoPendingFrameCondition] instance /// Factory constructor to parse an [InternalNoPendingFrameCondition] instance
/// from the given [SerializableWaitCondition] instance. /// from the given [SerializableWaitCondition] instance.
///
/// The [condition] argument must not be null.
factory _InternalNoPendingFrameCondition.deserialize(SerializableWaitCondition condition) { factory _InternalNoPendingFrameCondition.deserialize(SerializableWaitCondition condition) {
if (condition.conditionName != 'NoPendingFrameCondition') { if (condition.conditionName != 'NoPendingFrameCondition') {
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}'); throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
...@@ -95,8 +91,6 @@ class _InternalFirstFrameRasterizedCondition implements WaitCondition { ...@@ -95,8 +91,6 @@ class _InternalFirstFrameRasterizedCondition implements WaitCondition {
/// Factory constructor to parse an [InternalNoPendingFrameCondition] instance /// Factory constructor to parse an [InternalNoPendingFrameCondition] instance
/// from the given [SerializableWaitCondition] instance. /// from the given [SerializableWaitCondition] instance.
///
/// The [condition] argument must not be null.
factory _InternalFirstFrameRasterizedCondition.deserialize(SerializableWaitCondition condition) { factory _InternalFirstFrameRasterizedCondition.deserialize(SerializableWaitCondition condition) {
if (condition.conditionName != 'FirstFrameRasterizedCondition') { if (condition.conditionName != 'FirstFrameRasterizedCondition') {
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}'); throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
...@@ -121,8 +115,6 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition { ...@@ -121,8 +115,6 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition {
/// Factory constructor to parse an [_InternalNoPendingPlatformMessagesCondition] instance /// Factory constructor to parse an [_InternalNoPendingPlatformMessagesCondition] instance
/// from the given [SerializableWaitCondition] instance. /// from the given [SerializableWaitCondition] instance.
///
/// The [condition] argument must not be null.
factory _InternalNoPendingPlatformMessagesCondition.deserialize(SerializableWaitCondition condition) { factory _InternalNoPendingPlatformMessagesCondition.deserialize(SerializableWaitCondition condition) {
if (condition.conditionName != 'NoPendingPlatformMessagesCondition') { if (condition.conditionName != 'NoPendingPlatformMessagesCondition') {
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}'); throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
...@@ -150,14 +142,10 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition { ...@@ -150,14 +142,10 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition {
class _InternalCombinedCondition implements WaitCondition { class _InternalCombinedCondition implements WaitCondition {
/// Creates an [_InternalCombinedCondition] instance with the given list of /// Creates an [_InternalCombinedCondition] instance with the given list of
/// [conditions]. /// [conditions].
///
/// The [conditions] argument must not be null.
const _InternalCombinedCondition(this.conditions); const _InternalCombinedCondition(this.conditions);
/// Factory constructor to parse an [_InternalCombinedCondition] instance from /// Factory constructor to parse an [_InternalCombinedCondition] instance from
/// the given [SerializableWaitCondition] instance. /// the given [SerializableWaitCondition] instance.
///
/// The [condition] argument must not be null.
factory _InternalCombinedCondition.deserialize(SerializableWaitCondition condition) { factory _InternalCombinedCondition.deserialize(SerializableWaitCondition condition) {
if (condition.conditionName != 'CombinedCondition') { if (condition.conditionName != 'CombinedCondition') {
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}'); throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
...@@ -187,8 +175,6 @@ class _InternalCombinedCondition implements WaitCondition { ...@@ -187,8 +175,6 @@ class _InternalCombinedCondition implements WaitCondition {
} }
/// Parses a [WaitCondition] or its subclass from the given serializable [waitCondition]. /// Parses a [WaitCondition] or its subclass from the given serializable [waitCondition].
///
/// The [waitCondition] argument must not be null.
WaitCondition deserializeCondition(SerializableWaitCondition waitCondition) { WaitCondition deserializeCondition(SerializableWaitCondition waitCondition) {
final String conditionName = waitCondition.conditionName; final String conditionName = waitCondition.conditionName;
switch (conditionName) { switch (conditionName) {
......
...@@ -175,8 +175,6 @@ class AnimationSheetBuilder { ...@@ -175,8 +175,6 @@ class AnimationSheetBuilder {
/// [collate]. If neither condition is met, the frames are not recorded, which /// [collate]. If neither condition is met, the frames are not recorded, which
/// is useful during setup phases. /// is useful during setup phases.
/// ///
/// The `child` must not be null.
///
/// See also: /// See also:
/// ///
/// * [WidgetTester.pumpFrames], which renders a widget in a series of frames /// * [WidgetTester.pumpFrames], which renders a widget in a series of frames
......
...@@ -782,7 +782,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -782,7 +782,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// ///
/// The `description` is used by the [LiveTestWidgetsFlutterBinding] to /// The `description` is used by the [LiveTestWidgetsFlutterBinding] to
/// show a label on the screen during the test. The description comes from /// show a label on the screen during the test. The description comes from
/// the value passed to [testWidgets]. It must not be null. /// the value passed to [testWidgets].
Future<void> runTest( Future<void> runTest(
Future<void> Function() testBody, Future<void> Function() testBody,
VoidCallback invariantTester, { VoidCallback invariantTester, {
......
...@@ -1426,7 +1426,7 @@ abstract class WidgetController { ...@@ -1426,7 +1426,7 @@ abstract class WidgetController {
/// Specify `platform` as one of the platforms allowed in /// Specify `platform` as one of the platforms allowed in
/// [platform.Platform.operatingSystem] to make the event appear to be from /// [platform.Platform.operatingSystem] to make the event appear to be from
/// that type of system. Defaults to "web" on web, and "android" everywhere /// that type of system. Defaults to "web" on web, and "android" everywhere
/// else. Must not be null. /// else.
/// ///
/// Specify the `physicalKey` for the event to override what is included in /// Specify the `physicalKey` for the event to override what is included in
/// the simulated event. If not specified, it uses a default from the US /// the simulated event. If not specified, it uses a default from the US
...@@ -1471,7 +1471,7 @@ abstract class WidgetController { ...@@ -1471,7 +1471,7 @@ abstract class WidgetController {
/// Specify `platform` as one of the platforms allowed in /// Specify `platform` as one of the platforms allowed in
/// [platform.Platform.operatingSystem] to make the event appear to be from /// [platform.Platform.operatingSystem] to make the event appear to be from
/// that type of system. Defaults to "web" on web, and "android" everywhere /// that type of system. Defaults to "web" on web, and "android" everywhere
/// else. Must not be null. /// else.
/// ///
/// Specify the `physicalKey` for the event to override what is included in /// Specify the `physicalKey` for the event to override what is included in
/// the simulated event. If not specified, it uses a default from the US /// the simulated event. If not specified, it uses a default from the US
......
...@@ -47,8 +47,6 @@ typedef AllMessagesHandler = Future<ByteData?>? Function( ...@@ -47,8 +47,6 @@ typedef AllMessagesHandler = Future<ByteData?>? Function(
/// Listeners for these messages are configured using [setMessageHandler]. /// Listeners for these messages are configured using [setMessageHandler].
class TestDefaultBinaryMessenger extends BinaryMessenger { class TestDefaultBinaryMessenger extends BinaryMessenger {
/// Creates a [TestDefaultBinaryMessenger] instance. /// Creates a [TestDefaultBinaryMessenger] instance.
///
/// The [delegate] instance must not be null.
TestDefaultBinaryMessenger( TestDefaultBinaryMessenger(
this.delegate, { this.delegate, {
Map<String, MessageHandler> outboundHandlers = const <String, MessageHandler>{}, Map<String, MessageHandler> outboundHandlers = const <String, MessageHandler>{},
......
...@@ -28,8 +28,6 @@ List<Map<String, Object?>> _getList(Object? object, String errorMessage) { ...@@ -28,8 +28,6 @@ List<Map<String, Object?>> _getList(Object? object, String errorMessage) {
class IconTreeShaker { class IconTreeShaker {
/// Creates a wrapper for icon font subsetting. /// Creates a wrapper for icon font subsetting.
/// ///
/// The environment parameter must not be null.
///
/// If the `fontManifest` parameter is null, [enabled] will return false since /// If the `fontManifest` parameter is null, [enabled] will return false since
/// there are no fonts to shake. /// there are no fonts to shake.
/// ///
......
...@@ -44,8 +44,6 @@ class PlistParser { ...@@ -44,8 +44,6 @@ class PlistParser {
/// ///
/// If [plistFilePath] points to a non-existent file or a file that's not a /// If [plistFilePath] points to a non-existent file or a file that's not a
/// valid property list file, this will return null. /// valid property list file, this will return null.
///
/// The [plistFilePath] argument must not be null.
String? plistXmlContent(String plistFilePath) { String? plistXmlContent(String plistFilePath) {
if (!_fileSystem.isFileSync(_plutilExecutable)) { if (!_fileSystem.isFileSync(_plutilExecutable)) {
throw const FileNotFoundException(_plutilExecutable); throw const FileNotFoundException(_plutilExecutable);
...@@ -101,8 +99,6 @@ class PlistParser { ...@@ -101,8 +99,6 @@ class PlistParser {
/// ///
/// If [plistFilePath] points to a non-existent file or a file that's not a /// If [plistFilePath] points to a non-existent file or a file that's not a
/// valid property list file, this will return an empty map. /// valid property list file, this will return an empty map.
///
/// The [plistFilePath] argument must not be null.
Map<String, Object> parseFile(String plistFilePath) { Map<String, Object> parseFile(String plistFilePath) {
if (!_fileSystem.isFileSync(plistFilePath)) { if (!_fileSystem.isFileSync(plistFilePath)) {
return const <String, Object>{}; return const <String, Object>{};
...@@ -176,8 +172,6 @@ class PlistParser { ...@@ -176,8 +172,6 @@ class PlistParser {
/// valid property list file, this will return null. /// valid property list file, this will return null.
/// ///
/// If [key] is not found in the property list, this will return null. /// If [key] is not found in the property list, this will return null.
///
/// The [plistFilePath] and [key] arguments must not be null.
T? getValueFromFile<T>(String plistFilePath, String key) { T? getValueFromFile<T>(String plistFilePath, String key) {
final Map<String, dynamic> parsed = parseFile(plistFilePath); final Map<String, dynamic> parsed = parseFile(plistFilePath);
return parsed[key] as T?; return parsed[key] as T?;
......
...@@ -15,10 +15,9 @@ import 'plugin_registry.dart'; ...@@ -15,10 +15,9 @@ import 'plugin_registry.dart';
/// channel sends a stream of events to the handler listening on the /// channel sends a stream of events to the handler listening on the
/// framework-side. /// framework-side.
/// ///
/// The channel [name] must not be null. If no [codec] is provided, then /// If no [codec] is provided, then [StandardMethodCodec] is used. If no
/// [StandardMethodCodec] is used. If no [binaryMessenger] is provided, then /// [binaryMessenger] is provided, then [pluginBinaryMessenger], which sends
/// [pluginBinaryMessenger], which sends messages to the framework-side, /// messages to the framework-side, is used.
/// is used.
/// ///
/// Channels created using this class implement two methods for /// Channels created using this class implement two methods for
/// subscribing to the event stream. The methods use the encoding of /// subscribing to the event stream. The methods use the encoding of
...@@ -37,8 +36,6 @@ import 'plugin_registry.dart'; ...@@ -37,8 +36,6 @@ import 'plugin_registry.dart';
/// subscribed are silently discarded. /// subscribed are silently discarded.
class PluginEventChannel<T> { class PluginEventChannel<T> {
/// Creates a new plugin event channel. /// Creates a new plugin event channel.
///
/// The [name] and [codec] arguments must not be null.
const PluginEventChannel( const PluginEventChannel(
this.name, [ this.name, [
this.codec = const StandardMethodCodec(), this.codec = const StandardMethodCodec(),
...@@ -46,13 +43,11 @@ class PluginEventChannel<T> { ...@@ -46,13 +43,11 @@ class PluginEventChannel<T> {
]); ]);
/// The logical channel on which communication happens. /// The logical channel on which communication happens.
///
/// This must not be null.
final String name; final String name;
/// The message codec used by this channel. /// The message codec used by this channel.
/// ///
/// This must not be null. This defaults to [StandardMethodCodec]. /// Defaults to [StandardMethodCodec].
final MethodCodec codec; final MethodCodec codec;
/// The messenger used by this channel to send platform messages. /// The messenger used by this channel to send platform messages.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment