mirror of
https://github.com/flutter/flutter
synced 2024-08-27 12:00:58 +00:00
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
This commit is contained in:
parent
a63e19ba0f
commit
19dfde6989
|
@ -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 Category {
|
|||
/// 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 @@ class DocumentationIcon {
|
|||
/// 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;
|
||||
|
|
|
@ -54,9 +54,7 @@ class PartialStackFrame {
|
|||
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 @@ class RepetitiveStackFrameFilter extends StackFilter {
|
|||
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 @@ abstract class _ErrorDiagnostic extends DiagnosticsProperty<List<Object>> {
|
|||
String message, {
|
||||
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.flat,
|
||||
DiagnosticLevel level = DiagnosticLevel.info,
|
||||
}) : assert(message != null),
|
||||
super(
|
||||
}) : super(
|
||||
null,
|
||||
<Object>[message],
|
||||
showName: false,
|
||||
|
@ -217,8 +213,7 @@ abstract class _ErrorDiagnostic extends DiagnosticsProperty<List<Object>> {
|
|||
List<Object> messageParts, {
|
||||
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.flat,
|
||||
DiagnosticLevel level = DiagnosticLevel.info,
|
||||
}) : assert(messageParts != null),
|
||||
super(
|
||||
}) : super(
|
||||
null,
|
||||
messageParts,
|
||||
showName: false,
|
||||
|
@ -406,7 +401,7 @@ class FlutterErrorDetails with Diagnosticable {
|
|||
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 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
|
|||
///
|
||||
/// 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 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
|
|||
/// ```
|
||||
/// {@end-tool}
|
||||
static void reportError(FlutterErrorDetails details) {
|
||||
assert(details != null);
|
||||
assert(details.exception != null);
|
||||
onError?.call(details);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ class Factory<T> {
|
|||
/// 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;
|
||||
|
|
|
@ -327,7 +327,6 @@ abstract class BindingBase {
|
|||
]);
|
||||
}
|
||||
try {
|
||||
assert(instance != null);
|
||||
if (instance._debugConstructed && _debugInitializedType == null) {
|
||||
throw FlutterError.fromParts(<DiagnosticsNode>[
|
||||
ErrorSummary('Binding initialized without calling initInstances.'),
|
||||
|
@ -553,10 +552,8 @@ abstract class BindingBase {
|
|||
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 @@ abstract class BindingBase {
|
|||
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 @@ abstract class BindingBase {
|
|||
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 @@ abstract class BindingBase {
|
|||
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 @@ abstract class BindingBase {
|
|||
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 @@ abstract class BindingBase {
|
|||
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);
|
||||
|
|
|
@ -51,7 +51,6 @@ Future<Uint8List> consolidateHttpClientResponseBytes(
|
|||
bool autoUncompress = true,
|
||||
BytesReceivedCallback? onBytesReceived,
|
||||
}) {
|
||||
assert(autoUncompress != null);
|
||||
final Completer<Uint8List> completer = Completer<Uint8List>.sync();
|
||||
|
||||
final _OutputBuffer output = _OutputBuffer();
|
||||
|
|
|
@ -253,28 +253,7 @@ class TextTreeConfiguration {
|
|||
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 @@ class TextTreeRenderer {
|
|||
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 @@ class TextTreeRenderer {
|
|||
|
||||
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 @@ class TextTreeRenderer {
|
|||
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 @@ class TextTreeRenderer {
|
|||
|
||||
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 @@ abstract class DiagnosticsNode {
|
|||
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 @@ abstract class DiagnosticsNode {
|
|||
DiagnosticLevel level = DiagnosticLevel.info,
|
||||
bool allowWrap = true,
|
||||
}) {
|
||||
assert(style != null);
|
||||
assert(level != null);
|
||||
return DiagnosticsProperty<void>(
|
||||
'',
|
||||
null,
|
||||
|
@ -1728,7 +1701,6 @@ abstract class DiagnosticsNode {
|
|||
}) {
|
||||
String result = super.toString();
|
||||
assert(style != null);
|
||||
assert(minLevel != null);
|
||||
assert(() {
|
||||
if (_isSingleLine(style)) {
|
||||
result = toStringDeep(parentConfiguration: parentConfiguration, minLevel: minLevel);
|
||||
|
@ -1866,11 +1838,7 @@ class MessageProperty extends DiagnosticsProperty<void> {
|
|||
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 @@ class StringProperty extends DiagnosticsProperty<String> {
|
|||
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 @@ class DoubleProperty extends _NumProperty<double> {
|
|||
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 @@ class DoubleProperty extends _NumProperty<double> {
|
|||
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 @@ class IntProperty extends _NumProperty<int> {
|
|||
super.defaultValue,
|
||||
super.style,
|
||||
super.level,
|
||||
}) : assert(showName != null),
|
||||
assert(level != null),
|
||||
assert(style != null);
|
||||
});
|
||||
|
||||
@override
|
||||
String numberToString() => value.toString();
|
||||
|
@ -2075,8 +2034,7 @@ class PercentProperty extends DoubleProperty {
|
|||
super.tooltip,
|
||||
super.unit,
|
||||
super.level,
|
||||
}) : assert(showName != null),
|
||||
assert(level != null);
|
||||
});
|
||||
|
||||
@override
|
||||
String valueToString({ TextTreeConfiguration? parentConfiguration }) {
|
||||
|
@ -2150,9 +2108,7 @@ class FlagProperty extends DiagnosticsProperty<bool> {
|
|||
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 @@ class IterableProperty<T> extends DiagnosticsProperty<Iterable<T>> {
|
|||
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 @@ class EnumProperty<T> extends DiagnosticsProperty<T> {
|
|||
super.value, {
|
||||
super.defaultValue,
|
||||
super.level,
|
||||
}) : assert(level != null);
|
||||
});
|
||||
|
||||
@override
|
||||
String valueToString({ TextTreeConfiguration? parentConfiguration }) {
|
||||
|
@ -2382,9 +2335,7 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
|
|||
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 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
|
|||
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 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T?>> {
|
|||
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 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
|
|||
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 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
|
|||
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 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
|
|||
///
|
||||
/// `text` must not be null.
|
||||
String _addTooltip(String text) {
|
||||
assert(text != null);
|
||||
return tooltip == null ? text : '$text ($tooltip)';
|
||||
}
|
||||
|
||||
|
@ -2938,7 +2873,7 @@ class DiagnosticableNode<T extends Diagnosticable> extends DiagnosticsNode {
|
|||
super.name,
|
||||
required this.value,
|
||||
required super.style,
|
||||
}) : assert(value != null);
|
||||
});
|
||||
|
||||
@override
|
||||
final T value;
|
||||
|
|
|
@ -92,7 +92,6 @@ class AbstractNode {
|
|||
/// method, as in `super.attach(owner)`.
|
||||
@mustCallSuper
|
||||
void attach(covariant Object owner) {
|
||||
assert(owner != null);
|
||||
assert(_owner == null);
|
||||
_owner = owner;
|
||||
}
|
||||
|
@ -124,7 +123,6 @@ class AbstractNode {
|
|||
@protected
|
||||
@mustCallSuper
|
||||
void adoptChild(covariant AbstractNode child) {
|
||||
assert(child != null);
|
||||
assert(child._parent == null);
|
||||
assert(() {
|
||||
AbstractNode node = this;
|
||||
|
@ -147,7 +145,6 @@ class AbstractNode {
|
|||
@protected
|
||||
@mustCallSuper
|
||||
void dropChild(covariant AbstractNode child) {
|
||||
assert(child != null);
|
||||
assert(child._parent == this);
|
||||
assert(child.attached == attached);
|
||||
child._parent = null;
|
||||
|
|
|
@ -170,8 +170,7 @@ class WriteBuffer {
|
|||
/// 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;
|
||||
|
|
|
@ -35,16 +35,7 @@ class StackFrame {
|
|||
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 @@ class StackFrame {
|
|||
///
|
||||
/// 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 @@ class StackFrame {
|
|||
|
||||
/// 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 == '...') {
|
||||
|
|
|
@ -36,8 +36,7 @@ class ClampedSimulation extends Simulation {
|
|||
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
|
||||
|
|
|
@ -70,11 +70,7 @@ class GravitySimulation extends Simulation {
|
|||
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,
|
||||
|
|
|
@ -153,12 +153,6 @@ abstract class _SpringSolution {
|
|||
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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -151,8 +151,6 @@ class NetworkAssetBundle extends AssetBundle {
|
|||
/// 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 @@ abstract class CachingAssetBundle extends AssetBundle {
|
|||
/// 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>;
|
||||
}
|
||||
|
|
|
@ -651,8 +651,7 @@ class AutofillConfiguration {
|
|||
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 @@ class _AutofillScopeTextInputConfiguration extends TextInputConfiguration {
|
|||
_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 @@ class _AutofillScopeTextInputConfiguration extends TextInputConfiguration {
|
|||
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',
|
||||
|
|
|
@ -34,8 +34,7 @@ abstract class MessageCodec<T> {
|
|||
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 @@ class PlatformException implements Exception {
|
|||
this.message,
|
||||
this.details,
|
||||
this.stacktrace,
|
||||
}) : assert(code != null);
|
||||
});
|
||||
|
||||
/// An error code.
|
||||
final String code;
|
||||
|
|
|
@ -195,7 +195,6 @@ class JSONMethodCodec implements MethodCodec {
|
|||
|
||||
@override
|
||||
ByteData encodeErrorEnvelope({ required String code, String? message, Object? details}) {
|
||||
assert(code != null);
|
||||
return const JSONMessageCodec().encodeMessage(<Object?>[code, message, details])!;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,9 +104,7 @@ abstract class MouseCursorSession {
|
|||
/// 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 @@ abstract class MouseCursor with Diagnosticable {
|
|||
@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 @@ class _DeferringMouseCursor extends MouseCursor {
|
|||
/// 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 @@ class SystemMouseCursor extends MouseCursor {
|
|||
// 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.
|
||||
///
|
||||
|
|
|
@ -51,7 +51,7 @@ class MouseTrackerAnnotation with Diagnosticable {
|
|||
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.
|
||||
|
|
|
@ -163,9 +163,7 @@ class BasicMessageChannel<T> {
|
|||
/// 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 @@ class MethodChannel {
|
|||
/// 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 @@ class MethodChannel {
|
|||
/// 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 @@ class MethodChannel {
|
|||
/// 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 @@ class EventChannel {
|
|||
/// 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;
|
||||
|
|
|
@ -119,9 +119,6 @@ class PlatformViewsService {
|
|||
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 @@ class PlatformViewsService {
|
|||
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 @@ class PlatformViewsService {
|
|||
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 @@ class AndroidPointerProperties {
|
|||
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 @@ class AndroidPointerCoords {
|
|||
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 @@ class AndroidMotionEvent {
|
|||
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 @@ class _AndroidMotionEventConverter {
|
|||
<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 @@ class _AndroidMotionEventConverter {
|
|||
}
|
||||
|
||||
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 @@ abstract class AndroidViewController extends PlatformViewController {
|
|||
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 @@ abstract class AndroidViewController extends PlatformViewController {
|
|||
<PlatformViewCreatedCallback>[];
|
||||
|
||||
static int _getAndroidDirection(TextDirection direction) {
|
||||
assert(direction != null);
|
||||
switch (direction) {
|
||||
case TextDirection.ltr:
|
||||
return kAndroidLayoutDirectionLtr;
|
||||
|
@ -874,10 +833,9 @@ abstract class AndroidViewController extends PlatformViewController {
|
|||
///
|
||||
/// 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 @@ abstract class AndroidViewController extends PlatformViewController {
|
|||
/// 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 @@ abstract class AndroidViewController extends PlatformViewController {
|
|||
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 @@ class UiKitViewController {
|
|||
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 @@ class UiKitViewController {
|
|||
return;
|
||||
}
|
||||
|
||||
assert(layoutDirection != null);
|
||||
_layoutDirection = layoutDirection;
|
||||
|
||||
// TODO(amirh): invoke the iOS platform views channel direction method once available.
|
||||
|
|
|
@ -42,11 +42,7 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
|
|||
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 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
|
|||
|
||||
@override
|
||||
bool isModifierPressed(ModifierKey key, { KeyboardSide side = KeyboardSide.any }) {
|
||||
assert(side != null);
|
||||
switch (key) {
|
||||
case ModifierKey.controlModifier:
|
||||
return _isLeftRightModifierPressed(side, modifierControl, modifierLeftControl, modifierRightControl);
|
||||
|
|
|
@ -28,9 +28,7 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
|
|||
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 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
|
|||
|
||||
@override
|
||||
bool isModifierPressed(ModifierKey key, { KeyboardSide side = KeyboardSide.any }) {
|
||||
assert(side != null);
|
||||
switch (key) {
|
||||
case ModifierKey.controlModifier:
|
||||
return _isLeftRightModifierPressed(side, modifierControl, modifierLeftControl, modifierRightControl);
|
||||
|
|
|
@ -30,10 +30,7 @@ class RawKeyEventDataIos extends RawKeyEventData {
|
|||
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.
|
||||
///
|
||||
|
|
|
@ -33,12 +33,7 @@ class RawKeyEventDataLinux extends RawKeyEventData {
|
|||
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.
|
||||
///
|
||||
|
|
|
@ -42,10 +42,7 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
|
|||
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.
|
||||
///
|
||||
|
|
|
@ -35,8 +35,7 @@ class RawKeyEventDataWeb extends RawKeyEventData {
|
|||
this.location = 0,
|
||||
this.metaState = modifierNone,
|
||||
this.keyCode = 0,
|
||||
}) : assert(code != null),
|
||||
assert(metaState != null);
|
||||
});
|
||||
|
||||
/// The `KeyboardEvent.code` corresponding to this event.
|
||||
///
|
||||
|
|
|
@ -35,10 +35,7 @@ class RawKeyEventDataWindows extends RawKeyEventData {
|
|||
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.
|
||||
///
|
||||
|
|
|
@ -259,7 +259,6 @@ class RestorationManager extends ChangeNotifier {
|
|||
/// called.
|
||||
@protected
|
||||
void handleRestorationUpdateFromEngine({required bool enabled, required Uint8List? data}) {
|
||||
assert(enabled != null);
|
||||
assert(enabled || data == null);
|
||||
|
||||
_isReplacing = _rootBucketIsValid && enabled;
|
||||
|
@ -297,7 +296,6 @@ class RestorationManager extends ChangeNotifier {
|
|||
/// by the data.
|
||||
@protected
|
||||
Future<void> sendToEngine(Uint8List encodedData) {
|
||||
assert(encodedData != null);
|
||||
return SystemChannels.restoration.invokeMethod<void>(
|
||||
'put',
|
||||
encodedData,
|
||||
|
@ -344,7 +342,6 @@ class RestorationManager extends ChangeNotifier {
|
|||
@protected
|
||||
@visibleForTesting
|
||||
void scheduleSerializationFor(RestorationBucket bucket) {
|
||||
assert(bucket != null);
|
||||
assert(bucket._manager == this);
|
||||
assert(!_debugDoingUpdate);
|
||||
_bucketsNeedingSerialization.add(bucket);
|
||||
|
@ -366,7 +363,6 @@ class RestorationManager extends ChangeNotifier {
|
|||
@protected
|
||||
@visibleForTesting
|
||||
void unscheduleSerializationFor(RestorationBucket bucket) {
|
||||
assert(bucket != null);
|
||||
assert(bucket._manager == this);
|
||||
assert(!_debugDoingUpdate);
|
||||
_bucketsNeedingSerialization.remove(bucket);
|
||||
|
@ -502,8 +498,7 @@ class RestorationBucket {
|
|||
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 @@ class RestorationBucket {
|
|||
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 @@ class RestorationBucket {
|
|||
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 @@ class RestorationBucket {
|
|||
/// restoration ID.
|
||||
P? read<P>(String restorationId) {
|
||||
assert(_debugAssertNotDisposed());
|
||||
assert(restorationId != null);
|
||||
return _rawValues[restorationId] as P?;
|
||||
}
|
||||
|
||||
|
@ -657,7 +648,6 @@ class RestorationBucket {
|
|||
/// 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 @@ class RestorationBucket {
|
|||
/// 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 @@ class RestorationBucket {
|
|||
/// * [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 @@ class RestorationBucket {
|
|||
/// 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 @@ class RestorationBucket {
|
|||
/// 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 @@ class RestorationBucket {
|
|||
}
|
||||
|
||||
void _dropChild(RestorationBucket child) {
|
||||
assert(child != null);
|
||||
assert(child._parent == this);
|
||||
_removeChildData(child);
|
||||
child._parent = null;
|
||||
|
@ -876,7 +861,6 @@ class RestorationBucket {
|
|||
}
|
||||
|
||||
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 @@ class RestorationBucket {
|
|||
}
|
||||
|
||||
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 @@ class RestorationBucket {
|
|||
/// 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;
|
||||
}
|
||||
|
|
|
@ -27,9 +27,7 @@ class SuggestionSpan {
|
|||
///
|
||||
/// 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 @@ class SuggestionSpan {
|
|||
@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 @@ class DefaultSpellCheckService implements SpellCheckService {
|
|||
@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();
|
||||
|
|
|
@ -577,7 +577,6 @@ class SystemChrome {
|
|||
///
|
||||
/// * [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;
|
||||
|
|
|
@ -64,9 +64,7 @@ abstract class TextEditingDelta with Diagnosticable {
|
|||
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.
|
||||
|
|
|
@ -121,8 +121,7 @@ typedef TextInputFormatFunction = TextEditingValue Function(
|
|||
|
||||
/// Wiring for [TextInputFormatter.withFunction].
|
||||
class _SimpleTextInputFormatter extends TextInputFormatter {
|
||||
_SimpleTextInputFormatter(this.formatFunction)
|
||||
: assert(formatFunction != null);
|
||||
_SimpleTextInputFormatter(this.formatFunction);
|
||||
|
||||
final TextInputFormatFunction formatFunction;
|
||||
|
||||
|
@ -271,9 +270,7 @@ class FilteringTextInputFormatter extends TextInputFormatter {
|
|||
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.
|
||||
///
|
||||
|
|
|
@ -478,17 +478,8 @@ class TextInputConfiguration {
|
|||
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 @@ class RawFloatingCursorPoint {
|
|||
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 @@ class TextEditingValue {
|
|||
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 @@ mixin DeltaTextInputClient implements TextInputClient {
|
|||
/// 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 @@ class TextInputConnection {
|
|||
/// 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 @@ class TextInputConnection {
|
|||
/// 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 @@ class TextInputConnection {
|
|||
/// 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 @@ FloatingCursorDragState _toTextCursorAction(String state) {
|
|||
}
|
||||
|
||||
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 @@ class TextInput {
|
|||
/// 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 @@ class TextInput {
|
|||
// 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 @@ class TextInput {
|
|||
// 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 @@ class TextInput {
|
|||
// 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 @@ class TextInput {
|
|||
}
|
||||
|
||||
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 @@ class TextInput {
|
|||
/// * [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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue