mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Make sure that a Focus doesn't crash in 0x0 environment (#180674)
This is my attempt to handle https://github.com/flutter/flutter/issues/6537 for the Focus widget. Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
This commit is contained in:
parent
ac069ade5c
commit
be2f3bd443
@ -1882,6 +1882,25 @@ void main() {
|
||||
expect(focusNode.hasFocus, isTrue);
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('Focus does not crash at zero area', (WidgetTester tester) async {
|
||||
tester.view.physicalSize = Size.zero;
|
||||
final focusNode = FocusNode();
|
||||
addTearDown(tester.view.reset);
|
||||
addTearDown(focusNode.dispose);
|
||||
const key = Key('focus');
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Center(
|
||||
child: Focus(key: key, focusNode: focusNode, child: const Text('X')),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(tester.getSize(find.byKey(key)), Size.zero);
|
||||
focusNode.requestFocus();
|
||||
await tester.pump();
|
||||
});
|
||||
});
|
||||
|
||||
group('ExcludeFocus', () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user