File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
packages/flutter/test/material Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -3370,6 +3370,35 @@ void main() {
3370
3370
..rrect (color: const Color (0xffffffff )),
3371
3371
);
3372
3372
});
3373
+
3374
+ testWidgets ('Switch.onFocusChange callback' , (WidgetTester tester) async {
3375
+ final FocusNode focusNode = FocusNode (debugLabel: 'Switch' );
3376
+ bool focused = false ;
3377
+ await tester.pumpWidget (MaterialApp (
3378
+ home: Material (
3379
+ child: Center (
3380
+ child: Switch (
3381
+ value: true ,
3382
+ focusNode: focusNode,
3383
+ onFocusChange: (bool value) {
3384
+ focused = value;
3385
+ },
3386
+ onChanged: (bool newValue) {},
3387
+ ),
3388
+ ),
3389
+ ),
3390
+ ));
3391
+
3392
+ focusNode.requestFocus ();
3393
+ await tester.pump ();
3394
+ expect (focused, isTrue);
3395
+ expect (focusNode.hasFocus, isTrue);
3396
+
3397
+ focusNode.unfocus ();
3398
+ await tester.pump ();
3399
+ expect (focused, isFalse);
3400
+ expect (focusNode.hasFocus, isFalse);
3401
+ });
3373
3402
}
3374
3403
3375
3404
class DelayedImageProvider extends ImageProvider <DelayedImageProvider > {
You can’t perform that action at this time.
0 commit comments