Unverified Commit 19dfde69 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

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