Remove unnecessary null checks in `flutter/{foundation,services,physics}` (#118910)
* Remove unnecessary null checks in flutter/foundation
* Remove unnecessary null checks in flutter/services
* Remove unnecessary null checks in flutter/physics
diff --git a/packages/flutter/lib/src/foundation/annotations.dart b/packages/flutter/lib/src/foundation/annotations.dart
index b57bfac..3bc5e02 100644
--- a/packages/flutter/lib/src/foundation/annotations.dart
+++ b/packages/flutter/lib/src/foundation/annotations.dart
@@ -39,7 +39,7 @@
/// class that overrides the inline documentations' own description.
class Category {
/// Create an annotation to provide a categorization of a class.
- const Category(this.sections) : assert(sections != null);
+ const Category(this.sections);
/// The strings the correspond to the section and subsection of the
/// category represented by this object.
@@ -74,7 +74,7 @@
/// class that overrides the inline documentations' own description.
class DocumentationIcon {
/// Create an annotation to provide a URL to an image describing a class.
- const DocumentationIcon(this.url) : assert(url != null);
+ const DocumentationIcon(this.url);
/// The URL to an image that represents the annotated class.
final String url;
@@ -111,7 +111,7 @@
/// represents the class.
class Summary {
/// Create an annotation to provide a short description of a class.
- const Summary(this.text) : assert(text != null);
+ const Summary(this.text);
/// The text of the summary of the annotated class.
final String text;
diff --git a/packages/flutter/lib/src/foundation/assertions.dart b/packages/flutter/lib/src/foundation/assertions.dart
index 253b0ae..59abde7 100644
--- a/packages/flutter/lib/src/foundation/assertions.dart
+++ b/packages/flutter/lib/src/foundation/assertions.dart
@@ -54,9 +54,7 @@
required this.package,
required this.className,
required this.method,
- }) : assert(className != null),
- assert(method != null),
- assert(package != null);
+ });
/// An `<asynchronous suspension>` line in a stack trace.
static const PartialStackFrame asynchronousSuspension = PartialStackFrame(
@@ -128,8 +126,7 @@
const RepetitiveStackFrameFilter({
required this.frames,
required this.replacement,
- }) : assert(frames != null),
- assert(replacement != null);
+ });
/// The shape of this repetitive stack pattern.
final List<PartialStackFrame> frames;
@@ -177,8 +174,7 @@
String message, {
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.flat,
DiagnosticLevel level = DiagnosticLevel.info,
- }) : assert(message != null),
- super(
+ }) : super(
null,
<Object>[message],
showName: false,
@@ -217,8 +213,7 @@
List<Object> messageParts, {
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.flat,
DiagnosticLevel level = DiagnosticLevel.info,
- }) : assert(messageParts != null),
- super(
+ }) : super(
null,
messageParts,
showName: false,
@@ -406,7 +401,7 @@
this.stackFilter,
this.informationCollector,
this.silent = false,
- }) : assert(exception != null);
+ });
/// Creates a copy of the error details but with the given fields replaced
/// with new values.
@@ -1001,8 +996,6 @@
///
/// The default behavior for the [onError] handler is to call this function.
static void dumpErrorToConsole(FlutterErrorDetails details, { bool forceReport = false }) {
- assert(details != null);
- assert(details.exception != null);
bool isInDebugMode = false;
assert(() {
// In debug mode, we ignore the "silent" flag.
@@ -1182,8 +1175,6 @@
/// ```
/// {@end-tool}
static void reportError(FlutterErrorDetails details) {
- assert(details != null);
- assert(details.exception != null);
onError?.call(details);
}
}
diff --git a/packages/flutter/lib/src/foundation/basic_types.dart b/packages/flutter/lib/src/foundation/basic_types.dart
index dc58411..9bc8c6a 100644
--- a/packages/flutter/lib/src/foundation/basic_types.dart
+++ b/packages/flutter/lib/src/foundation/basic_types.dart
@@ -231,7 +231,7 @@
/// Creates a new factory.
///
/// The `constructor` parameter must not be null.
- const Factory(this.constructor) : assert(constructor != null);
+ const Factory(this.constructor);
/// Creates a new object of type T.
final ValueGetter<T> constructor;
diff --git a/packages/flutter/lib/src/foundation/binding.dart b/packages/flutter/lib/src/foundation/binding.dart
index 9bcf928..c7fce10 100644
--- a/packages/flutter/lib/src/foundation/binding.dart
+++ b/packages/flutter/lib/src/foundation/binding.dart
@@ -327,7 +327,6 @@
]);
}
try {
- assert(instance != null);
if (instance._debugConstructed && _debugInitializedType == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('Binding initialized without calling initInstances.'),
@@ -553,10 +552,8 @@
Future<void> lockEvents(Future<void> Function() callback) {
final developer.TimelineTask timelineTask = developer.TimelineTask()..start('Lock events');
- assert(callback != null);
_lockCount += 1;
final Future<void> future = callback();
- assert(future != null, 'The lockEvents() callback returned null; it should return a Future<void> that completes when the lock is to expire.');
future.whenComplete(() {
_lockCount -= 1;
if (!locked) {
@@ -627,8 +624,6 @@
required String name,
required AsyncCallback callback,
}) {
- assert(name != null);
- assert(callback != null);
registerServiceExtension(
name: name,
callback: (Map<String, String> parameters) async {
@@ -658,9 +653,6 @@
required AsyncValueGetter<bool> getter,
required AsyncValueSetter<bool> setter,
}) {
- assert(name != null);
- assert(getter != null);
- assert(setter != null);
registerServiceExtension(
name: name,
callback: (Map<String, String> parameters) async {
@@ -692,9 +684,6 @@
required AsyncValueGetter<double> getter,
required AsyncValueSetter<double> setter,
}) {
- assert(name != null);
- assert(getter != null);
- assert(setter != null);
registerServiceExtension(
name: name,
callback: (Map<String, String> parameters) async {
@@ -754,9 +743,6 @@
required AsyncValueGetter<String> getter,
required AsyncValueSetter<String> setter,
}) {
- assert(name != null);
- assert(getter != null);
- assert(setter != null);
registerServiceExtension(
name: name,
callback: (Map<String, String> parameters) async {
@@ -825,8 +811,6 @@
required String name,
required ServiceExtensionCallback callback,
}) {
- assert(name != null);
- assert(callback != null);
final String methodName = 'ext.flutter.$name';
developer.registerExtension(methodName, (String method, Map<String, String> parameters) async {
assert(method == methodName);
diff --git a/packages/flutter/lib/src/foundation/consolidate_response.dart b/packages/flutter/lib/src/foundation/consolidate_response.dart
index 4d0f44c..94160ec 100644
--- a/packages/flutter/lib/src/foundation/consolidate_response.dart
+++ b/packages/flutter/lib/src/foundation/consolidate_response.dart
@@ -51,7 +51,6 @@
bool autoUncompress = true,
BytesReceivedCallback? onBytesReceived,
}) {
- assert(autoUncompress != null);
final Completer<Uint8List> completer = Completer<Uint8List>.sync();
final _OutputBuffer output = _OutputBuffer();
diff --git a/packages/flutter/lib/src/foundation/diagnostics.dart b/packages/flutter/lib/src/foundation/diagnostics.dart
index 80906dd..48e4161 100644
--- a/packages/flutter/lib/src/foundation/diagnostics.dart
+++ b/packages/flutter/lib/src/foundation/diagnostics.dart
@@ -253,28 +253,7 @@
this.beforeName = '',
this.suffixLineOne = '',
this.mandatoryFooter = '',
- }) : assert(prefixLineOne != null),
- assert(prefixOtherLines != null),
- assert(prefixLastChildLineOne != null),
- assert(prefixOtherLinesRootNode != null),
- assert(linkCharacter != null),
- assert(propertyPrefixIfChildren != null),
- assert(propertyPrefixNoChildren != null),
- assert(lineBreak != null),
- assert(lineBreakProperties != null),
- assert(afterName != null),
- assert(afterDescriptionIfBody != null),
- assert(afterDescription != null),
- assert(beforeProperties != null),
- assert(afterProperties != null),
- assert(propertySeparator != null),
- assert(bodyIndent != null),
- assert(footer != null),
- assert(showChildren != null),
- assert(addBlankLineIfNoChildren != null),
- assert(isNameOnOwnLine != null),
- assert(isBlankLineBetweenPropertiesAndChildren != null),
- childLinkSpace = ' ' * linkCharacter.length;
+ }) : childLinkSpace = ' ' * linkCharacter.length;
/// Prefix to add to the first line to display a child with this style.
final String prefixLineOne;
@@ -1113,8 +1092,7 @@
int wrapWidth = 100,
int wrapWidthProperties = 65,
int maxDescendentsTruncatableNode = -1,
- }) : assert(minLevel != null),
- _minLevel = minLevel,
+ }) : _minLevel = minLevel,
_wrapWidth = wrapWidth,
_wrapWidthProperties = wrapWidthProperties,
_maxDescendentsTruncatableNode = maxDescendentsTruncatableNode;
@@ -1218,7 +1196,7 @@
List<DiagnosticsNode> children = node.getChildren();
- String? description = node.toDescription(parentConfiguration: parentConfiguration);
+ String description = node.toDescription(parentConfiguration: parentConfiguration);
if (config.beforeName.isNotEmpty) {
builder.write(config.beforeName);
}
@@ -1229,7 +1207,7 @@
if (uppercaseTitle) {
name = name?.toUpperCase();
}
- if (description == null || description.isEmpty) {
+ if (description.isEmpty) {
if (node.showName && name != null) {
builder.write(name, allowWrap: wrapName);
}
@@ -1388,7 +1366,6 @@
for (int i = 0; i < children.length; i++) {
final DiagnosticsNode child = children[i];
- assert(child != null);
final TextTreeConfiguration childConfig = _childTextConfiguration(child, config)!;
if (i == children.length - 1) {
final String lastChildPrefixLineOne = '$prefixChildrenRaw${childConfig.prefixLastChildLineOne}';
@@ -1463,12 +1440,10 @@
this.showName = true,
this.showSeparator = true,
this.linePrefix,
- }) : assert(showName != null),
- assert(showSeparator != null),
- // A name ending with ':' indicates that the user forgot that the ':' will
- // be automatically added for them when generating descriptions of the
- // property.
- assert(
+ }) : assert(
+ // A name ending with ':' indicates that the user forgot that the ':' will
+ // be automatically added for them when generating descriptions of the
+ // property.
name == null || !name.endsWith(':'),
'Names of diagnostic nodes must not end with colons.\n'
'name:\n'
@@ -1490,8 +1465,6 @@
DiagnosticLevel level = DiagnosticLevel.info,
bool allowWrap = true,
}) {
- assert(style != null);
- assert(level != null);
return DiagnosticsProperty<void>(
'',
null,
@@ -1728,7 +1701,6 @@
}) {
String result = super.toString();
assert(style != null);
- assert(minLevel != null);
assert(() {
if (_isSingleLine(style)) {
result = toStringDeep(parentConfiguration: parentConfiguration, minLevel: minLevel);
@@ -1866,11 +1838,7 @@
String message, {
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.singleLine,
DiagnosticLevel level = DiagnosticLevel.info,
- }) : assert(name != null),
- assert(message != null),
- assert(style != null),
- assert(level != null),
- super(name, null, description: message, style: style, level: level);
+ }) : super(name, null, description: message, style: style, level: level);
}
/// Property which encloses its string [value] in quotes.
@@ -1894,10 +1862,7 @@
super.ifEmpty,
super.style,
super.level,
- }) : assert(showName != null),
- assert(quoted != null),
- assert(style != null),
- assert(level != null);
+ });
/// Whether the value is enclosed in double quotes.
final bool quoted;
@@ -2005,9 +1970,7 @@
super.showName,
super.style,
super.level,
- }) : assert(showName != null),
- assert(style != null),
- assert(level != null);
+ });
/// Property with a [value] that is computed only when needed.
///
@@ -2024,9 +1987,7 @@
super.tooltip,
super.defaultValue,
super.level,
- }) : assert(showName != null),
- assert(level != null),
- super.lazy();
+ }) : super.lazy();
@override
String numberToString() => debugFormatDouble(value);
@@ -2048,9 +2009,7 @@
super.defaultValue,
super.style,
super.level,
- }) : assert(showName != null),
- assert(level != null),
- assert(style != null);
+ });
@override
String numberToString() => value.toString();
@@ -2075,8 +2034,7 @@
super.tooltip,
super.unit,
super.level,
- }) : assert(showName != null),
- assert(level != null);
+ });
@override
String valueToString({ TextTreeConfiguration? parentConfiguration }) {
@@ -2150,9 +2108,7 @@
bool showName = false,
Object? defaultValue,
DiagnosticLevel level = DiagnosticLevel.info,
- }) : assert(showName != null),
- assert(level != null),
- assert(ifTrue != null || ifFalse != null),
+ }) : assert(ifTrue != null || ifFalse != null),
super(
name,
value,
@@ -2254,10 +2210,7 @@
super.showName,
super.showSeparator,
super.level,
- }) : assert(style != null),
- assert(showName != null),
- assert(showSeparator != null),
- assert(level != null);
+ });
@override
String valueToString({TextTreeConfiguration? parentConfiguration}) {
@@ -2335,7 +2288,7 @@
super.value, {
super.defaultValue,
super.level,
- }) : assert(level != null);
+ });
@override
String valueToString({ TextTreeConfiguration? parentConfiguration }) {
@@ -2382,9 +2335,7 @@
super.ifNull,
super.showName = false,
super.level,
- }) : assert(ifPresent != null || ifNull != null),
- assert(showName != null),
- assert(level != null);
+ }) : assert(ifPresent != null || ifNull != null);
/// Shorthand constructor to describe whether the property has a value.
///
@@ -2396,9 +2347,7 @@
String super.name,
super.value, {
super.level,
- }) : assert(name != null),
- assert(level != null),
- ifPresent = 'has $name',
+ }) : ifPresent = 'has $name',
super(
showName: false,
);
@@ -2495,17 +2444,13 @@
super.showName,
super.showSeparator,
super.level,
- }) : assert(value != null),
- assert(showName != null),
- assert(showSeparator != null),
- assert(level != null);
+ });
@override
Map<String, T?> get value => super.value!;
@override
String valueToString({TextTreeConfiguration? parentConfiguration}) {
- assert(value != null);
if (!_hasNonNullEntry() && ifEmpty != null) {
return ifEmpty!;
}
@@ -2598,11 +2543,7 @@
this.allowNameWrap = true,
DiagnosticsTreeStyle super.style = DiagnosticsTreeStyle.singleLine,
DiagnosticLevel level = DiagnosticLevel.info,
- }) : assert(showName != null),
- assert(showSeparator != null),
- assert(style != null),
- assert(level != null),
- _description = description,
+ }) : _description = description,
_valueComputed = true,
_value = value,
_computeValue = null,
@@ -2640,12 +2581,7 @@
this.allowNameWrap = true,
DiagnosticsTreeStyle super.style = DiagnosticsTreeStyle.singleLine,
DiagnosticLevel level = DiagnosticLevel.info,
- }) : assert(showName != null),
- assert(showSeparator != null),
- assert(defaultValue == kNoDefaultValue || defaultValue is T?),
- assert(missingIfNull != null),
- assert(style != null),
- assert(level != null),
+ }) : assert(defaultValue == kNoDefaultValue || defaultValue is T?),
_description = description,
_valueComputed = false,
_value = null,
@@ -2765,7 +2701,6 @@
///
/// `text` must not be null.
String _addTooltip(String text) {
- assert(text != null);
return tooltip == null ? text : '$text ($tooltip)';
}
@@ -2938,7 +2873,7 @@
super.name,
required this.value,
required super.style,
- }) : assert(value != null);
+ });
@override
final T value;
diff --git a/packages/flutter/lib/src/foundation/node.dart b/packages/flutter/lib/src/foundation/node.dart
index f8c377b..6e830f1 100644
--- a/packages/flutter/lib/src/foundation/node.dart
+++ b/packages/flutter/lib/src/foundation/node.dart
@@ -92,7 +92,6 @@
/// method, as in `super.attach(owner)`.
@mustCallSuper
void attach(covariant Object owner) {
- assert(owner != null);
assert(_owner == null);
_owner = owner;
}
@@ -124,7 +123,6 @@
@protected
@mustCallSuper
void adoptChild(covariant AbstractNode child) {
- assert(child != null);
assert(child._parent == null);
assert(() {
AbstractNode node = this;
@@ -147,7 +145,6 @@
@protected
@mustCallSuper
void dropChild(covariant AbstractNode child) {
- assert(child != null);
assert(child._parent == this);
assert(child.attached == attached);
child._parent = null;
diff --git a/packages/flutter/lib/src/foundation/serialization.dart b/packages/flutter/lib/src/foundation/serialization.dart
index b0ade7d..bdeaecc 100644
--- a/packages/flutter/lib/src/foundation/serialization.dart
+++ b/packages/flutter/lib/src/foundation/serialization.dart
@@ -170,8 +170,7 @@
/// The byte order used is [Endian.host] throughout.
class ReadBuffer {
/// Creates a [ReadBuffer] for reading from the specified [data].
- ReadBuffer(this.data)
- : assert(data != null);
+ ReadBuffer(this.data);
/// The underlying data being read.
final ByteData data;
diff --git a/packages/flutter/lib/src/foundation/stack_frame.dart b/packages/flutter/lib/src/foundation/stack_frame.dart
index 1a18d2d..5e22e1e 100644
--- a/packages/flutter/lib/src/foundation/stack_frame.dart
+++ b/packages/flutter/lib/src/foundation/stack_frame.dart
@@ -35,16 +35,7 @@
required this.method,
this.isConstructor = false,
required this.source,
- }) : assert(number != null),
- assert(column != null),
- assert(line != null),
- assert(method != null),
- assert(packageScheme != null),
- assert(package != null),
- assert(packagePath != null),
- assert(className != null),
- assert(isConstructor != null),
- assert(source != null);
+ });
/// A stack frame representing an asynchronous suspension.
static const StackFrame asynchronousSuspension = StackFrame(
@@ -74,13 +65,11 @@
///
/// This is normally useful with [StackTrace.current].
static List<StackFrame> fromStackTrace(StackTrace stack) {
- assert(stack != null);
return fromStackString(stack.toString());
}
/// Parses a list of [StackFrame]s from the [StackTrace.toString] method.
static List<StackFrame> fromStackString(String stack) {
- assert(stack != null);
return stack
.trim()
.split('\n')
@@ -181,7 +170,6 @@
/// Parses a single [StackFrame] from a single line of a [StackTrace].
static StackFrame? fromStackTraceLine(String line) {
- assert(line != null);
if (line == '<asynchronous suspension>') {
return asynchronousSuspension;
} else if (line == '...') {
diff --git a/packages/flutter/lib/src/physics/clamped_simulation.dart b/packages/flutter/lib/src/physics/clamped_simulation.dart
index 943ea80..dfd889d 100644
--- a/packages/flutter/lib/src/physics/clamped_simulation.dart
+++ b/packages/flutter/lib/src/physics/clamped_simulation.dart
@@ -36,8 +36,7 @@
this.xMax = double.infinity,
this.dxMin = double.negativeInfinity,
this.dxMax = double.infinity,
- }) : assert(simulation != null),
- assert(xMax >= xMin),
+ }) : assert(xMax >= xMin),
assert(dxMax >= dxMin);
/// The simulation being clamped. Calls to [x], [dx], and [isDone] are
diff --git a/packages/flutter/lib/src/physics/gravity_simulation.dart b/packages/flutter/lib/src/physics/gravity_simulation.dart
index d3715e2..56f02ed 100644
--- a/packages/flutter/lib/src/physics/gravity_simulation.dart
+++ b/packages/flutter/lib/src/physics/gravity_simulation.dart
@@ -70,11 +70,7 @@
double distance,
double endDistance,
double velocity,
- ) : assert(acceleration != null),
- assert(distance != null),
- assert(velocity != null),
- assert(endDistance != null),
- assert(endDistance >= 0),
+ ) : assert(endDistance >= 0),
_a = acceleration,
_x = distance,
_v = velocity,
diff --git a/packages/flutter/lib/src/physics/spring_simulation.dart b/packages/flutter/lib/src/physics/spring_simulation.dart
index 9080310..b4b615a 100644
--- a/packages/flutter/lib/src/physics/spring_simulation.dart
+++ b/packages/flutter/lib/src/physics/spring_simulation.dart
@@ -153,12 +153,6 @@
double initialPosition,
double initialVelocity,
) {
- assert(spring != null);
- assert(spring.mass != null);
- assert(spring.stiffness != null);
- assert(spring.damping != null);
- assert(initialPosition != null);
- assert(initialVelocity != null);
final double cmk = spring.damping * spring.damping - 4 * spring.mass * spring.stiffness;
if (cmk == 0.0) {
return _CriticalSolution(spring, initialPosition, initialVelocity);
diff --git a/packages/flutter/lib/src/physics/utils.dart b/packages/flutter/lib/src/physics/utils.dart
index 7b9501b..7a8f82e 100644
--- a/packages/flutter/lib/src/physics/utils.dart
+++ b/packages/flutter/lib/src/physics/utils.dart
@@ -8,7 +8,6 @@
/// The `a` and `b` arguments may be null. A null value is only considered
/// near-equal to another null value.
bool nearEqual(double? a, double? b, double epsilon) {
- assert(epsilon != null);
assert(epsilon >= 0.0);
if (a == null || b == null) {
return a == b;
diff --git a/packages/flutter/lib/src/services/asset_bundle.dart b/packages/flutter/lib/src/services/asset_bundle.dart
index 776035a..971fdaf 100644
--- a/packages/flutter/lib/src/services/asset_bundle.dart
+++ b/packages/flutter/lib/src/services/asset_bundle.dart
@@ -151,8 +151,6 @@
/// fetched.
@override
Future<T> loadStructuredData<T>(String key, Future<T> Function(String value) parser) async {
- assert(key != null);
- assert(parser != null);
return parser(await loadString(key));
}
@@ -196,8 +194,6 @@
/// callback synchronously.
@override
Future<T> loadStructuredData<T>(String key, Future<T> Function(String value) parser) {
- assert(key != null);
- assert(parser != null);
if (_structuredDataCache.containsKey(key)) {
return _structuredDataCache[key]! as Future<T>;
}
diff --git a/packages/flutter/lib/src/services/autofill.dart b/packages/flutter/lib/src/services/autofill.dart
index f1dd457..8cf825f 100644
--- a/packages/flutter/lib/src/services/autofill.dart
+++ b/packages/flutter/lib/src/services/autofill.dart
@@ -651,8 +651,7 @@
this.autofillHints = const <String>[],
this.hintText,
required this.currentEditingValue,
- }) : assert(uniqueIdentifier != null),
- assert(autofillHints != null);
+ });
/// An [AutofillConfiguration] that indicates the [AutofillClient] does not
/// wish to be autofilled.
@@ -810,9 +809,7 @@
_AutofillScopeTextInputConfiguration({
required this.allConfigurations,
required TextInputConfiguration currentClientConfiguration,
- }) : assert(allConfigurations != null),
- assert(currentClientConfiguration != null),
- super(inputType: currentClientConfiguration.inputType,
+ }) : super(inputType: currentClientConfiguration.inputType,
obscureText: currentClientConfiguration.obscureText,
autocorrect: currentClientConfiguration.autocorrect,
smartDashesType: currentClientConfiguration.smartDashesType,
@@ -843,7 +840,6 @@
mixin AutofillScopeMixin implements AutofillScope {
@override
TextInputConnection attach(TextInputClient trigger, TextInputConfiguration configuration) {
- assert(trigger != null);
assert(
!autofillClients.any((AutofillClient client) => !client.textInputConfiguration.autofillConfiguration.enabled),
'Every client in AutofillScope.autofillClients must enable autofill',
diff --git a/packages/flutter/lib/src/services/message_codec.dart b/packages/flutter/lib/src/services/message_codec.dart
index fd45d29..cc2efd4 100644
--- a/packages/flutter/lib/src/services/message_codec.dart
+++ b/packages/flutter/lib/src/services/message_codec.dart
@@ -34,8 +34,7 @@
class MethodCall {
/// Creates a [MethodCall] representing the invocation of [method] with the
/// specified [arguments].
- const MethodCall(this.method, [this.arguments])
- : assert(method != null);
+ const MethodCall(this.method, [this.arguments]);
/// The name of the method to be called.
final String method;
@@ -114,7 +113,7 @@
this.message,
this.details,
this.stacktrace,
- }) : assert(code != null);
+ });
/// An error code.
final String code;
diff --git a/packages/flutter/lib/src/services/message_codecs.dart b/packages/flutter/lib/src/services/message_codecs.dart
index 6aecc86..fcd9073 100644
--- a/packages/flutter/lib/src/services/message_codecs.dart
+++ b/packages/flutter/lib/src/services/message_codecs.dart
@@ -195,7 +195,6 @@
@override
ByteData encodeErrorEnvelope({ required String code, String? message, Object? details}) {
- assert(code != null);
return const JSONMessageCodec().encodeMessage(<Object?>[code, message, details])!;
}
}
diff --git a/packages/flutter/lib/src/services/mouse_cursor.dart b/packages/flutter/lib/src/services/mouse_cursor.dart
index 5abe5cc..c698aa0 100644
--- a/packages/flutter/lib/src/services/mouse_cursor.dart
+++ b/packages/flutter/lib/src/services/mouse_cursor.dart
@@ -104,9 +104,7 @@
/// Create a session.
///
/// All arguments must be non-null.
- MouseCursorSession(this.cursor, this.device)
- : assert(cursor != null),
- assert(device != null);
+ MouseCursorSession(this.cursor, this.device);
/// The cursor that created this session.
final MouseCursor cursor;
@@ -215,7 +213,7 @@
@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
final String debugDescription = this.debugDescription;
- if (minLevel.index >= DiagnosticLevel.info.index && debugDescription != null) {
+ if (minLevel.index >= DiagnosticLevel.info.index) {
return debugDescription;
}
return super.toString(minLevel: minLevel);
@@ -262,7 +260,6 @@
/// Returns the first cursor that is not a [MouseCursor.defer].
static MouseCursor? firstNonDeferred(Iterable<MouseCursor> cursors) {
for (final MouseCursor cursor in cursors) {
- assert(cursor != null);
if (cursor != MouseCursor.defer) {
return cursor;
}
@@ -358,7 +355,7 @@
// the supported system cursors are enumerated in [SystemMouseCursors].
const SystemMouseCursor._({
required this.kind,
- }) : assert(kind != null);
+ });
/// A string that identifies the kind of the cursor.
///
diff --git a/packages/flutter/lib/src/services/mouse_tracking.dart b/packages/flutter/lib/src/services/mouse_tracking.dart
index a66216d..e0c405b 100644
--- a/packages/flutter/lib/src/services/mouse_tracking.dart
+++ b/packages/flutter/lib/src/services/mouse_tracking.dart
@@ -51,7 +51,7 @@
this.onExit,
this.cursor = MouseCursor.defer,
this.validForMouseTracker = true,
- }) : assert(cursor != null);
+ });
/// Triggered when a mouse pointer, with or without buttons pressed, has
/// entered the region and [validForMouseTracker] is true.
diff --git a/packages/flutter/lib/src/services/platform_channel.dart b/packages/flutter/lib/src/services/platform_channel.dart
index d718de9..6106302 100644
--- a/packages/flutter/lib/src/services/platform_channel.dart
+++ b/packages/flutter/lib/src/services/platform_channel.dart
@@ -163,9 +163,7 @@
/// The [name] and [codec] arguments cannot be null. The default [ServicesBinding.defaultBinaryMessenger]
/// instance is used if [binaryMessenger] is null.
const BasicMessageChannel(this.name, this.codec, { BinaryMessenger? binaryMessenger })
- : assert(name != null),
- assert(codec != null),
- _binaryMessenger = binaryMessenger;
+ : _binaryMessenger = binaryMessenger;
/// The logical channel on which communication happens, not null.
final String name;
@@ -253,9 +251,7 @@
/// The [name] and [codec] arguments cannot be null. The default [ServicesBinding.defaultBinaryMessenger]
/// instance is used if [binaryMessenger] is null.
const MethodChannel(this.name, [this.codec = const StandardMethodCodec(), BinaryMessenger? binaryMessenger ])
- : assert(name != null),
- assert(codec != null),
- _binaryMessenger = binaryMessenger;
+ : _binaryMessenger = binaryMessenger;
/// The logical channel on which communication happens, not null.
final String name;
@@ -300,7 +296,6 @@
/// nullable.
@optionalTypeArgs
Future<T?> _invokeMethod<T>(String method, { required bool missingOk, dynamic arguments }) async {
- assert(method != null);
final ByteData input = codec.encodeMethodCall(MethodCall(method, arguments));
final ByteData? result =
!kReleaseMode && debugProfilePlatformChannels ?
@@ -535,7 +530,7 @@
/// Any other exception results in an error envelope being sent.
void setMethodCallHandler(Future<dynamic> Function(MethodCall call)? handler) {
assert(
- _binaryMessenger != null || ServicesBinding.instance != null,
+ _binaryMessenger != null || BindingBase.debugBindingType() != null,
'Cannot set the method call handler before the binary messenger has been initialized. '
'This happens when you call setMethodCallHandler() before the WidgetsFlutterBinding '
'has been initialized. You can fix this by either calling WidgetsFlutterBinding.ensureInitialized() '
@@ -609,9 +604,7 @@
/// Neither [name] nor [codec] may be null. The default [ServicesBinding.defaultBinaryMessenger]
/// instance is used if [binaryMessenger] is null.
const EventChannel(this.name, [this.codec = const StandardMethodCodec(), BinaryMessenger? binaryMessenger])
- : assert(name != null),
- assert(codec != null),
- _binaryMessenger = binaryMessenger;
+ : _binaryMessenger = binaryMessenger;
/// The logical channel on which communication happens, not null.
final String name;
diff --git a/packages/flutter/lib/src/services/platform_views.dart b/packages/flutter/lib/src/services/platform_views.dart
index 001acb7..fb903dd 100644
--- a/packages/flutter/lib/src/services/platform_views.dart
+++ b/packages/flutter/lib/src/services/platform_views.dart
@@ -119,9 +119,6 @@
MessageCodec<dynamic>? creationParamsCodec,
VoidCallback? onFocus,
}) {
- assert(id != null);
- assert(viewType != null);
- assert(layoutDirection != null);
assert(creationParams == null || creationParamsCodec != null);
final TextureAndroidViewController controller = TextureAndroidViewController._(
@@ -150,9 +147,6 @@
MessageCodec<dynamic>? creationParamsCodec,
VoidCallback? onFocus,
}) {
- assert(id != null);
- assert(viewType != null);
- assert(layoutDirection != null);
assert(creationParams == null || creationParamsCodec != null);
final SurfaceAndroidViewController controller = SurfaceAndroidViewController._(
@@ -222,9 +216,6 @@
MessageCodec<dynamic>? creationParamsCodec,
VoidCallback? onFocus,
}) async {
- assert(id != null);
- assert(viewType != null);
- assert(layoutDirection != null);
assert(creationParams == null || creationParamsCodec != null);
// TODO(amirh): pass layoutDirection once the system channel supports it.
@@ -258,8 +249,7 @@
const AndroidPointerProperties({
required this.id,
required this.toolType,
- }) : assert(id != null),
- assert(toolType != null);
+ });
/// See Android's [MotionEvent.PointerProperties#id](https://developer.android.com/reference/android/view/MotionEvent.PointerProperties.html#id).
final int id;
@@ -308,15 +298,7 @@
required this.touchMinor,
required this.x,
required this.y,
- }) : assert(orientation != null),
- assert(pressure != null),
- assert(size != null),
- assert(toolMajor != null),
- assert(toolMinor != null),
- assert(touchMajor != null),
- assert(touchMinor != null),
- assert(x != null),
- assert(y != null);
+ });
/// The orientation of the touch area and tool area in radians clockwise from vertical.
///
@@ -404,21 +386,7 @@
required this.source,
required this.flags,
required this.motionEventId,
- }) : assert(downTime != null),
- assert(eventTime != null),
- assert(action != null),
- assert(pointerCount != null),
- assert(pointerProperties != null),
- assert(pointerCoords != null),
- assert(metaState != null),
- assert(buttonState != null),
- assert(xPrecision != null),
- assert(yPrecision != null),
- assert(deviceId != null),
- assert(edgeFlags != null),
- assert(source != null),
- assert(flags != null),
- assert(pointerProperties.length == pointerCount),
+ }) : assert(pointerProperties.length == pointerCount),
assert(pointerCoords.length == pointerCount);
/// The time (in ms) when the user originally pressed down to start a stream of position events,
@@ -532,12 +500,7 @@
<int, AndroidPointerProperties>{};
final Set<int> usedAndroidPointerIds = <int>{};
- PointTransformer get pointTransformer => _pointTransformer;
- late PointTransformer _pointTransformer;
- set pointTransformer(PointTransformer transformer) {
- assert(transformer != null);
- _pointTransformer = transformer;
- }
+ late PointTransformer pointTransformer;
int? downTimeMillis;
@@ -554,7 +517,7 @@
}
void updatePointerPositions(PointerEvent event) {
- final Offset position = _pointTransformer(event.position);
+ final Offset position = pointTransformer(event.position);
pointerPositions[event.pointer] = AndroidPointerCoords(
orientation: event.orientation,
pressure: event.pressure,
@@ -691,10 +654,7 @@
required TextDirection layoutDirection,
dynamic creationParams,
MessageCodec<dynamic>? creationParamsCodec,
- }) : assert(viewId != null),
- assert(viewType != null),
- assert(layoutDirection != null),
- assert(creationParams == null || creationParamsCodec != null),
+ }) : assert(creationParams == null || creationParamsCodec != null),
_viewType = viewType,
_layoutDirection = layoutDirection,
_creationParams = creationParams == null ? null : _CreationParams(creationParams, creationParamsCodec!);
@@ -755,7 +715,6 @@
<PlatformViewCreatedCallback>[];
static int _getAndroidDirection(TextDirection direction) {
- assert(direction != null);
switch (direction) {
case TextDirection.ltr:
return kAndroidLayoutDirectionLtr;
@@ -874,10 +833,9 @@
///
/// This is required to convert a [PointerEvent] to an [AndroidMotionEvent].
/// It is typically provided by using [RenderBox.globalToLocal].
- PointTransformer get pointTransformer => _motionEventConverter._pointTransformer;
+ PointTransformer get pointTransformer => _motionEventConverter.pointTransformer;
set pointTransformer(PointTransformer transformer) {
- assert(transformer != null);
- _motionEventConverter._pointTransformer = transformer;
+ _motionEventConverter.pointTransformer = transformer;
}
/// Whether the platform view has already been created.
@@ -886,14 +844,12 @@
/// Adds a callback that will get invoke after the platform view has been
/// created.
void addOnPlatformViewCreatedListener(PlatformViewCreatedCallback listener) {
- assert(listener != null);
assert(_state != _AndroidViewState.disposed);
_platformViewCreatedCallbacks.add(listener);
}
/// Removes a callback added with [addOnPlatformViewCreatedListener].
void removeOnPlatformViewCreatedListener(PlatformViewCreatedCallback listener) {
- assert(listener != null);
assert(_state != _AndroidViewState.disposed);
_platformViewCreatedCallbacks.remove(listener);
}
@@ -914,7 +870,6 @@
return;
}
- assert(layoutDirection != null);
_layoutDirection = layoutDirection;
// If the view was not yet created we just update _layoutDirection and return, as the new
@@ -1361,9 +1316,7 @@
UiKitViewController._(
this.id,
TextDirection layoutDirection,
- ) : assert(id != null),
- assert(layoutDirection != null),
- _layoutDirection = layoutDirection;
+ ) : _layoutDirection = layoutDirection;
/// The unique identifier of the iOS view controlled by this controller.
@@ -1384,7 +1337,6 @@
return;
}
- assert(layoutDirection != null);
_layoutDirection = layoutDirection;
// TODO(amirh): invoke the iOS platform views channel direction method once available.
diff --git a/packages/flutter/lib/src/services/raw_keyboard_android.dart b/packages/flutter/lib/src/services/raw_keyboard_android.dart
index 7c39a3e..4de79da 100644
--- a/packages/flutter/lib/src/services/raw_keyboard_android.dart
+++ b/packages/flutter/lib/src/services/raw_keyboard_android.dart
@@ -42,11 +42,7 @@
this.productId = 0,
this.deviceId = 0,
this.repeatCount = 0,
- }) : assert(flags != null),
- assert(codePoint != null),
- assert(keyCode != null),
- assert(scanCode != null),
- assert(metaState != null);
+ });
/// The current set of additional flags for this event.
///
@@ -227,7 +223,6 @@
@override
bool isModifierPressed(ModifierKey key, { KeyboardSide side = KeyboardSide.any }) {
- assert(side != null);
switch (key) {
case ModifierKey.controlModifier:
return _isLeftRightModifierPressed(side, modifierControl, modifierLeftControl, modifierRightControl);
diff --git a/packages/flutter/lib/src/services/raw_keyboard_fuchsia.dart b/packages/flutter/lib/src/services/raw_keyboard_fuchsia.dart
index 5158117..3f74d08 100644
--- a/packages/flutter/lib/src/services/raw_keyboard_fuchsia.dart
+++ b/packages/flutter/lib/src/services/raw_keyboard_fuchsia.dart
@@ -28,9 +28,7 @@
this.hidUsage = 0,
this.codePoint = 0,
this.modifiers = 0,
- }) : assert(hidUsage != null),
- assert(codePoint != null),
- assert(modifiers != null);
+ });
/// The USB HID usage.
///
@@ -107,7 +105,6 @@
@override
bool isModifierPressed(ModifierKey key, { KeyboardSide side = KeyboardSide.any }) {
- assert(side != null);
switch (key) {
case ModifierKey.controlModifier:
return _isLeftRightModifierPressed(side, modifierControl, modifierLeftControl, modifierRightControl);
diff --git a/packages/flutter/lib/src/services/raw_keyboard_ios.dart b/packages/flutter/lib/src/services/raw_keyboard_ios.dart
index 4ee5f5d..00ecd43 100644
--- a/packages/flutter/lib/src/services/raw_keyboard_ios.dart
+++ b/packages/flutter/lib/src/services/raw_keyboard_ios.dart
@@ -30,10 +30,7 @@
this.charactersIgnoringModifiers = '',
this.keyCode = 0,
this.modifiers = 0,
- }) : assert(characters != null),
- assert(charactersIgnoringModifiers != null),
- assert(keyCode != null),
- assert(modifiers != null);
+ });
/// The Unicode characters associated with a key-up or key-down event.
///
diff --git a/packages/flutter/lib/src/services/raw_keyboard_linux.dart b/packages/flutter/lib/src/services/raw_keyboard_linux.dart
index c7e0d21..70d139d 100644
--- a/packages/flutter/lib/src/services/raw_keyboard_linux.dart
+++ b/packages/flutter/lib/src/services/raw_keyboard_linux.dart
@@ -33,12 +33,7 @@
this.modifiers = 0,
required this.isDown,
this.specifiedLogicalKey,
- }) : assert(scanCode != null),
- assert(unicodeScalarValues != null),
- assert((unicodeScalarValues & ~LogicalKeyboardKey.valueMask) == 0),
- assert(keyCode != null),
- assert(modifiers != null),
- assert(keyHelper != null);
+ }) : assert((unicodeScalarValues & ~LogicalKeyboardKey.valueMask) == 0);
/// A helper class that abstracts the fetching of the toolkit-specific mappings.
///
diff --git a/packages/flutter/lib/src/services/raw_keyboard_macos.dart b/packages/flutter/lib/src/services/raw_keyboard_macos.dart
index 952ec0c..c4e140b 100644
--- a/packages/flutter/lib/src/services/raw_keyboard_macos.dart
+++ b/packages/flutter/lib/src/services/raw_keyboard_macos.dart
@@ -42,10 +42,7 @@
this.keyCode = 0,
this.modifiers = 0,
this.specifiedLogicalKey,
- }) : assert(characters != null),
- assert(charactersIgnoringModifiers != null),
- assert(keyCode != null),
- assert(modifiers != null);
+ });
/// The Unicode characters associated with a key-up or key-down event.
///
diff --git a/packages/flutter/lib/src/services/raw_keyboard_web.dart b/packages/flutter/lib/src/services/raw_keyboard_web.dart
index 3ad7a6f..8cc289b 100644
--- a/packages/flutter/lib/src/services/raw_keyboard_web.dart
+++ b/packages/flutter/lib/src/services/raw_keyboard_web.dart
@@ -35,8 +35,7 @@
this.location = 0,
this.metaState = modifierNone,
this.keyCode = 0,
- }) : assert(code != null),
- assert(metaState != null);
+ });
/// The `KeyboardEvent.code` corresponding to this event.
///
diff --git a/packages/flutter/lib/src/services/raw_keyboard_windows.dart b/packages/flutter/lib/src/services/raw_keyboard_windows.dart
index d9f9797..a8b01d0 100644
--- a/packages/flutter/lib/src/services/raw_keyboard_windows.dart
+++ b/packages/flutter/lib/src/services/raw_keyboard_windows.dart
@@ -35,10 +35,7 @@
this.scanCode = 0,
this.characterCodePoint = 0,
this.modifiers = 0,
- }) : assert(keyCode != null),
- assert(scanCode != null),
- assert(characterCodePoint != null),
- assert(modifiers != null);
+ });
/// The hardware key code corresponding to this key event.
///
diff --git a/packages/flutter/lib/src/services/restoration.dart b/packages/flutter/lib/src/services/restoration.dart
index e2f59d5..1ff50e6 100644
--- a/packages/flutter/lib/src/services/restoration.dart
+++ b/packages/flutter/lib/src/services/restoration.dart
@@ -259,7 +259,6 @@
/// called.
@protected
void handleRestorationUpdateFromEngine({required bool enabled, required Uint8List? data}) {
- assert(enabled != null);
assert(enabled || data == null);
_isReplacing = _rootBucketIsValid && enabled;
@@ -297,7 +296,6 @@
/// by the data.
@protected
Future<void> sendToEngine(Uint8List encodedData) {
- assert(encodedData != null);
return SystemChannels.restoration.invokeMethod<void>(
'put',
encodedData,
@@ -344,7 +342,6 @@
@protected
@visibleForTesting
void scheduleSerializationFor(RestorationBucket bucket) {
- assert(bucket != null);
assert(bucket._manager == this);
assert(!_debugDoingUpdate);
_bucketsNeedingSerialization.add(bucket);
@@ -366,7 +363,6 @@
@protected
@visibleForTesting
void unscheduleSerializationFor(RestorationBucket bucket) {
- assert(bucket != null);
assert(bucket._manager == this);
assert(!_debugDoingUpdate);
_bucketsNeedingSerialization.remove(bucket);
@@ -502,8 +498,7 @@
RestorationBucket.empty({
required String restorationId,
required Object? debugOwner,
- }) : assert(restorationId != null),
- _restorationId = restorationId,
+ }) : _restorationId = restorationId,
_rawData = <String, Object?>{} {
assert(() {
_debugOwner = debugOwner;
@@ -537,8 +532,7 @@
RestorationBucket.root({
required RestorationManager manager,
required Map<Object?, Object?>? rawData,
- }) : assert(manager != null),
- _manager = manager,
+ }) : _manager = manager,
_rawData = rawData ?? <Object?, Object?>{},
_restorationId = 'root' {
assert(() {
@@ -561,9 +555,7 @@
required String restorationId,
required RestorationBucket parent,
required Object? debugOwner,
- }) : assert(restorationId != null),
- assert(parent != null),
- assert(parent._rawChildren[restorationId] != null),
+ }) : assert(parent._rawChildren[restorationId] != null),
_manager = parent._manager,
_parent = parent,
_rawData = parent._rawChildren[restorationId]! as Map<Object?, Object?>,
@@ -635,7 +627,6 @@
/// restoration ID.
P? read<P>(String restorationId) {
assert(_debugAssertNotDisposed());
- assert(restorationId != null);
return _rawValues[restorationId] as P?;
}
@@ -657,7 +648,6 @@
/// restoration ID.
void write<P>(String restorationId, P value) {
assert(_debugAssertNotDisposed());
- assert(restorationId != null);
assert(debugIsSerializableForRestoration(value));
if (_rawValues[restorationId] != value || !_rawValues.containsKey(restorationId)) {
_rawValues[restorationId] = value;
@@ -679,7 +669,6 @@
/// restoration ID.
P? remove<P>(String restorationId) {
assert(_debugAssertNotDisposed());
- assert(restorationId != null);
final bool needsUpdate = _rawValues.containsKey(restorationId);
final P? result = _rawValues.remove(restorationId) as P?;
if (_rawValues.isEmpty) {
@@ -701,7 +690,6 @@
/// * [remove], which removes a value from the bucket.
bool contains(String restorationId) {
assert(_debugAssertNotDisposed());
- assert(restorationId != null);
return _rawValues.containsKey(restorationId);
}
@@ -737,7 +725,6 @@
/// delete the information stored in it from the app's restoration data.
RestorationBucket claimChild(String restorationId, {required Object? debugOwner}) {
assert(_debugAssertNotDisposed());
- assert(restorationId != null);
// There are three cases to consider:
// 1. Claiming an ID that has already been claimed.
// 2. Claiming an ID that doesn't yet exist in [_rawChildren].
@@ -787,7 +774,6 @@
/// No-op if the provided bucket is already a child of this bucket.
void adoptChild(RestorationBucket child) {
assert(_debugAssertNotDisposed());
- assert(child != null);
if (child._parent != this) {
child._parent?._removeChildData(child);
child._parent = this;
@@ -801,7 +787,6 @@
}
void _dropChild(RestorationBucket child) {
- assert(child != null);
assert(child._parent == this);
_removeChildData(child);
child._parent = null;
@@ -876,7 +861,6 @@
}
void _removeChildData(RestorationBucket child) {
- assert(child != null);
assert(child._parent == this);
if (_claimedChildren.remove(child.restorationId) == child) {
_rawChildren.remove(child.restorationId);
@@ -901,7 +885,6 @@
}
void _addChildData(RestorationBucket child) {
- assert(child != null);
assert(child._parent == this);
if (_claimedChildren.containsKey(child.restorationId)) {
// Delay addition until the end of the frame in the hopes that the current
@@ -944,7 +927,6 @@
/// another ID, or has moved it to a new parent via [adoptChild].
void rename(String newRestorationId) {
assert(_debugAssertNotDisposed());
- assert(newRestorationId != null);
if (newRestorationId == restorationId) {
return;
}
diff --git a/packages/flutter/lib/src/services/spell_check.dart b/packages/flutter/lib/src/services/spell_check.dart
index 4ca29d2..3f70829 100644
--- a/packages/flutter/lib/src/services/spell_check.dart
+++ b/packages/flutter/lib/src/services/spell_check.dart
@@ -27,9 +27,7 @@
///
/// The [range] and replacement [suggestions] must all not
/// be null.
- const SuggestionSpan(this.range, this.suggestions)
- : assert(range != null),
- assert(suggestions != null);
+ const SuggestionSpan(this.range, this.suggestions);
/// The misspelled range of text.
final TextRange range;
@@ -58,9 +56,7 @@
@immutable
class SpellCheckResults {
/// Creates results based off those received by spell checking some text input.
- const SpellCheckResults(this.spellCheckedText, this.suggestionSpans)
- : assert(spellCheckedText != null),
- assert(suggestionSpans != null);
+ const SpellCheckResults(this.spellCheckedText, this.suggestionSpans);
/// The text that the [suggestionSpans] correspond to.
final String spellCheckedText;
@@ -170,8 +166,6 @@
@override
Future<List<SuggestionSpan>?> fetchSpellCheckSuggestions(
Locale locale, String text) async {
- assert(locale != null);
- assert(text != null);
final List<dynamic> rawResults;
final String languageTag = locale.toLanguageTag();
diff --git a/packages/flutter/lib/src/services/system_chrome.dart b/packages/flutter/lib/src/services/system_chrome.dart
index f97c14b..a8bab27 100644
--- a/packages/flutter/lib/src/services/system_chrome.dart
+++ b/packages/flutter/lib/src/services/system_chrome.dart
@@ -577,7 +577,6 @@
///
/// * [AnnotatedRegion], the widget used to place data into the layer tree.
static void setSystemUIOverlayStyle(SystemUiOverlayStyle style) {
- assert(style != null);
if (_pendingStyle != null) {
// The microtask has already been queued; just update the pending value.
_pendingStyle = style;
diff --git a/packages/flutter/lib/src/services/text_editing_delta.dart b/packages/flutter/lib/src/services/text_editing_delta.dart
index 090de35..3357a7d 100644
--- a/packages/flutter/lib/src/services/text_editing_delta.dart
+++ b/packages/flutter/lib/src/services/text_editing_delta.dart
@@ -64,9 +64,7 @@
required this.oldText,
required this.selection,
required this.composing,
- }) : assert(oldText != null),
- assert(selection != null),
- assert(composing != null);
+ });
/// Creates an instance of this class from a JSON object by inferring the
/// type of delta based on values sent from the engine.
diff --git a/packages/flutter/lib/src/services/text_formatter.dart b/packages/flutter/lib/src/services/text_formatter.dart
index 8ba5d0d..a822b5c 100644
--- a/packages/flutter/lib/src/services/text_formatter.dart
+++ b/packages/flutter/lib/src/services/text_formatter.dart
@@ -121,8 +121,7 @@
/// Wiring for [TextInputFormatter.withFunction].
class _SimpleTextInputFormatter extends TextInputFormatter {
- _SimpleTextInputFormatter(this.formatFunction)
- : assert(formatFunction != null);
+ _SimpleTextInputFormatter(this.formatFunction);
final TextInputFormatFunction formatFunction;
@@ -271,9 +270,7 @@
this.filterPattern, {
required this.allow,
this.replacementString = '',
- }) : assert(filterPattern != null),
- assert(allow != null),
- assert(replacementString != null);
+ });
/// Creates a formatter that only allows characters matching a pattern.
///
diff --git a/packages/flutter/lib/src/services/text_input.dart b/packages/flutter/lib/src/services/text_input.dart
index 3506da6..b346660 100644
--- a/packages/flutter/lib/src/services/text_input.dart
+++ b/packages/flutter/lib/src/services/text_input.dart
@@ -478,17 +478,8 @@
this.autofillConfiguration = AutofillConfiguration.disabled,
this.enableIMEPersonalizedLearning = true,
this.enableDeltaModel = false,
- }) : assert(inputType != null),
- assert(obscureText != null),
- smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
- smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
- assert(autocorrect != null),
- assert(enableSuggestions != null),
- assert(keyboardAppearance != null),
- assert(inputAction != null),
- assert(textCapitalization != null),
- assert(enableIMEPersonalizedLearning != null),
- assert(enableDeltaModel != null);
+ }) : smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
+ smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled);
/// The type of information for which to optimize the text input control.
final TextInputType inputType;
@@ -746,8 +737,7 @@
RawFloatingCursorPoint({
this.offset,
required this.state,
- }) : assert(state != null),
- assert(state != FloatingCursorDragState.Update || offset != null);
+ }) : assert(state != FloatingCursorDragState.Update || offset != null);
/// The raw position of the floating cursor as determined by the iOS sdk.
final Offset? offset;
@@ -773,13 +763,7 @@
this.text = '',
this.selection = const TextSelection.collapsed(offset: -1),
this.composing = TextRange.empty,
- }) : assert(text != null),
- // The constructor does not verify that `selection` and `composing` are
- // valid ranges within `text`, and is unable to do so due to limitation
- // of const constructors. Some checks are performed by assertion in
- // other occasions. See `_textRangeIsValid`.
- assert(selection != null),
- assert(composing != null);
+ });
/// Creates an instance of this class from a JSON object.
factory TextEditingValue.fromJSON(Map<String, dynamic> encoded) {
@@ -1300,8 +1284,7 @@
/// the system's text input using a [TextInputConnection].
class TextInputConnection {
TextInputConnection._(this._client)
- : assert(_client != null),
- _id = _nextId++;
+ : _id = _nextId++;
Size? _cachedSize;
Matrix4? _cachedTransform;
@@ -1318,7 +1301,6 @@
/// application code will likely break text input for the application.
@visibleForTesting
static void debugResetId({int to = 1}) {
- assert(to != null);
assert(() {
_nextId = to;
return true;
@@ -1395,7 +1377,6 @@
/// This information is used for positioning the IME candidates menu on each
/// platform.
void setComposingRect(Rect rect) {
- assert(rect != null);
if (rect == _cachedRect) {
return;
}
@@ -1407,7 +1388,6 @@
/// Sends the coordinates of caret rect. This is used on macOS for positioning
/// the accent selection menu.
void setCaretRect(Rect rect) {
- assert(rect != null);
if (rect == _cachedCaretRect) {
return;
}
@@ -1515,7 +1495,6 @@
}
RawFloatingCursorPoint _toTextPoint(FloatingCursorDragState state, Map<String, dynamic> encoded) {
- assert(state != null, 'You must provide a state to set a new editing point.');
assert(encoded['X'] != null, 'You must provide a value for the horizontal location of the floating cursor.');
assert(encoded['Y'] != null, 'You must provide a value for the vertical location of the floating cursor.');
final Offset offset = state == FloatingCursorDragState.Update
@@ -1699,8 +1678,6 @@
/// should call [TextInputConnection.close] on the returned
/// [TextInputConnection].
static TextInputConnection attach(TextInputClient client, TextInputConfiguration configuration) {
- assert(client != null);
- assert(configuration != null);
final TextInputConnection connection = TextInputConnection._(client);
_instance._attach(connection, configuration);
return connection;
@@ -1710,9 +1687,6 @@
// by [attach] and by [_handleTextInputInvocation] for the
// `TextInputClient.requestExistingInputState` method.
void _attach(TextInputConnection connection, TextInputConfiguration configuration) {
- assert(connection != null);
- assert(connection._client != null);
- assert(configuration != null);
assert(_debugEnsureInputActionWorksOnPlatform(configuration.inputAction));
_currentConnection = connection;
_currentConfiguration = configuration;
@@ -1806,7 +1780,6 @@
// The requestExistingInputState request needs to be handled regardless of
// the client ID, as long as we have a _currentConnection.
if (method == 'TextInputClient.requestExistingInputState') {
- assert(_currentConnection!._client != null);
_attach(_currentConnection!, _currentConfiguration);
final TextEditingValue? editingValue = _currentConnection!._client.currentTextEditingValue;
if (editingValue != null) {
@@ -1820,7 +1793,6 @@
// The updateEditingStateWithTag request (autofill) can come up even to a
// text field that doesn't have a connection.
if (method == 'TextInputClient.updateEditingStateWithTag') {
- assert(_currentConnection!._client != null);
final TextInputClient client = _currentConnection!._client;
final AutofillScope? scope = client.currentAutofillScope;
final Map<String, dynamic> editingValue = args[1] as Map<String, dynamic>;
@@ -1951,14 +1923,12 @@
}
void _updateConfig(TextInputConfiguration configuration) {
- assert(configuration != null);
for (final TextInputControl control in _inputControls) {
control.updateConfig(configuration);
}
}
void _setEditingState(TextEditingValue value) {
- assert(value != null);
for (final TextInputControl control in _inputControls) {
control.setEditingState(value);
}
@@ -2094,7 +2064,6 @@
/// * [AutofillGroup.onDisposeAction], a configurable action that runs when a
/// topmost [AutofillGroup] is getting disposed.
static void finishAutofillContext({ bool shouldSave = true }) {
- assert(shouldSave != null);
for (final TextInputControl control in TextInput._instance._inputControls) {
control.finishAutofillContext(shouldSave: shouldSave);
}