forked from firka/flutter
Migrate android_semantics_testing to null safety (#84136)
This commit is contained in:
committed by
GitHub
parent
3858cc655c
commit
0d1a8a7798
@@ -53,19 +53,19 @@ class AndroidSemanticsNode {
|
||||
/// ]
|
||||
/// }
|
||||
factory AndroidSemanticsNode.deserialize(String value) {
|
||||
return AndroidSemanticsNode._(json.decode(value) as Map<String, Object>);
|
||||
return AndroidSemanticsNode._(json.decode(value) as Map<String, Object?>);
|
||||
}
|
||||
|
||||
final Map<String, Object> _values;
|
||||
final Map<String, Object?> _values;
|
||||
final List<AndroidSemanticsNode> _children = <AndroidSemanticsNode>[];
|
||||
|
||||
Map<String, Object> get _flags => _values['flags'] as Map<String, Object>;
|
||||
Map<String, Object?> get _flags => _values['flags']! as Map<String, Object?>;
|
||||
|
||||
/// The text value of the semantics node.
|
||||
///
|
||||
/// This is produced by combining the value, label, and hint fields from
|
||||
/// the Flutter [SemanticsNode].
|
||||
String get text => _values['text'] as String;
|
||||
String get text => _values['text']! as String;
|
||||
|
||||
/// The contentDescription of the semantics node.
|
||||
///
|
||||
@@ -75,7 +75,7 @@ class AndroidSemanticsNode {
|
||||
///
|
||||
/// This is produced by combining the value, label, and hint fields from
|
||||
/// the Flutter [SemanticsNode].
|
||||
String get contentDescription => _values['contentDescription'] as String;
|
||||
String get contentDescription => _values['contentDescription']! as String;
|
||||
|
||||
/// The className of the semantics node.
|
||||
///
|
||||
@@ -84,10 +84,10 @@ class AndroidSemanticsNode {
|
||||
///
|
||||
/// If a more specific value isn't provided, it defaults to
|
||||
/// "android.view.View".
|
||||
String get className => _values['className'] as String;
|
||||
String get className => _values['className']! as String;
|
||||
|
||||
/// The identifier for this semantics node.
|
||||
int get id => _values['id'] as int;
|
||||
int get id => _values['id']! as int;
|
||||
|
||||
/// The children of this semantics node.
|
||||
List<AndroidSemanticsNode> get children => _children;
|
||||
@@ -95,50 +95,50 @@ class AndroidSemanticsNode {
|
||||
/// Whether the node is currently in a checked state.
|
||||
///
|
||||
/// Equivalent to [SemanticsFlag.isChecked].
|
||||
bool get isChecked => _flags['isChecked'] as bool;
|
||||
bool get isChecked => _flags['isChecked']! as bool;
|
||||
|
||||
/// Whether the node can be in a checked state.
|
||||
///
|
||||
/// Equivalent to [SemanticsFlag.hasCheckedState]
|
||||
bool get isCheckable => _flags['isCheckable'] as bool;
|
||||
bool get isCheckable => _flags['isCheckable']! as bool;
|
||||
|
||||
/// Whether the node is editable.
|
||||
///
|
||||
/// This is usually only applied to text fields, which map
|
||||
/// to "android.widget.EditText".
|
||||
bool get isEditable => _flags['isEditable'] as bool;
|
||||
bool get isEditable => _flags['isEditable']! as bool;
|
||||
|
||||
/// Whether the node is enabled.
|
||||
bool get isEnabled => _flags['isEnabled'] as bool;
|
||||
bool get isEnabled => _flags['isEnabled']! as bool;
|
||||
|
||||
/// Whether the node is focusable.
|
||||
bool get isFocusable => _flags['isFocusable'] as bool;
|
||||
bool get isFocusable => _flags['isFocusable']! as bool;
|
||||
|
||||
/// Whether the node is focused.
|
||||
bool get isFocused => _flags['isFocused'] as bool;
|
||||
bool get isFocused => _flags['isFocused']! as bool;
|
||||
|
||||
/// Whether the node is considered a heading.
|
||||
bool get isHeading => _flags['isHeading'] as bool;
|
||||
bool get isHeading => _flags['isHeading']! as bool;
|
||||
|
||||
/// Whether the node represents a password field.
|
||||
///
|
||||
/// Equivalent to [SemanticsFlag.isObscured].
|
||||
bool get isPassword => _flags['isPassword'] as bool;
|
||||
bool get isPassword => _flags['isPassword']! as bool;
|
||||
|
||||
/// Whether the node is long clickable.
|
||||
///
|
||||
/// Equivalent to having [SemanticsAction.longPress].
|
||||
bool get isLongClickable => _flags['isLongClickable'] as bool;
|
||||
bool get isLongClickable => _flags['isLongClickable']! as bool;
|
||||
|
||||
/// Gets a [Rect] which defines the position and size of the semantics node.
|
||||
Rect getRect() {
|
||||
final Map<String, Object> rawRect = _values['rect'] as Map<String, Object>;
|
||||
final Map<String, Object?> rawRect = _values['rect']! as Map<String, Object?>;
|
||||
final Map<String, int> rect = rawRect.cast<String, int>();
|
||||
return Rect.fromLTRB(
|
||||
rect['left'].toDouble(),
|
||||
rect['top'].toDouble(),
|
||||
rect['right'].toDouble(),
|
||||
rect['bottom'].toDouble(),
|
||||
rect['left']!.toDouble(),
|
||||
rect['top']!.toDouble(),
|
||||
rect['right']!.toDouble(),
|
||||
rect['bottom']!.toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class AndroidSemanticsNode {
|
||||
|
||||
/// Gets a list of [AndroidSemanticsActions] which are defined for the node.
|
||||
List<AndroidSemanticsAction> getActions() => <AndroidSemanticsAction>[
|
||||
for (final int id in (_values['actions'] as List<dynamic>).cast<int>()) AndroidSemanticsAction.deserialize(id),
|
||||
for (final int id in (_values['actions']! as List<dynamic>).cast<int>()) AndroidSemanticsAction.deserialize(id)!,
|
||||
];
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user