@@ -3101,6 +3101,92 @@ void main() {
31013101 );
31023102 });
31033103
3104+ testWidgets ('Drag feedback is put on root overlay with [rootOverlay] flag' , (WidgetTester tester) async {
3105+ final GlobalKey <NavigatorState > rootNavigatorKey = GlobalKey <NavigatorState >();
3106+ final GlobalKey <NavigatorState > childNavigatorKey = GlobalKey <NavigatorState >();
3107+ // Create a [MaterialApp], with a nested [Navigator], which has the
3108+ // [Draggable].
3109+ await tester.pumpWidget (MaterialApp (
3110+ navigatorKey: rootNavigatorKey,
3111+ home: Column (
3112+ children: < Widget > [
3113+ SizedBox (
3114+ height: 200.0 ,
3115+ child: Navigator (
3116+ key: childNavigatorKey,
3117+ onGenerateRoute: (RouteSettings settings) {
3118+ if (settings.name == '/' ) {
3119+ return MaterialPageRoute <void >(
3120+ settings: settings,
3121+ builder: (BuildContext context) => const LongPressDraggable <int >(
3122+ data: 1 ,
3123+ feedback: Text ('Dragging' ),
3124+ rootOverlay: true ,
3125+ child: Text ('Source' ),
3126+ ),
3127+ );
3128+ }
3129+ throw UnsupportedError ('Unsupported route: $settings ' );
3130+ },
3131+ ),
3132+ ),
3133+ DragTarget <int >(
3134+ builder: (BuildContext context, List <int ?> data, List <dynamic > rejects) {
3135+ return const SizedBox (
3136+ height: 300.0 , child: Center (child: Text ('Target 1' )),
3137+ );
3138+ },
3139+ ),
3140+ ],
3141+ ),
3142+ ));
3143+
3144+ final Offset firstLocation = tester.getCenter (find.text ('Source' ));
3145+ final TestGesture gesture =
3146+ await tester.startGesture (firstLocation, pointer: 7 );
3147+ await tester.pump (kLongPressTimeout);
3148+
3149+ final Offset secondLocation = tester.getCenter (find.text ('Target 1' ));
3150+ await gesture.moveTo (secondLocation);
3151+ await tester.pump ();
3152+
3153+ // Expect that the feedback widget is a descendant of the root overlay,
3154+ // but not a descendant of the child overlay.
3155+ expect (
3156+ find.descendant (
3157+ of: find.byType (Overlay ).first,
3158+ matching: find.text ('Dragging' ),
3159+ ),
3160+ findsOneWidget,
3161+ );
3162+ expect (
3163+ find.descendant (
3164+ of: find.byType (Overlay ).last,
3165+ matching: find.text ('Dragging' ),
3166+ ),
3167+ findsNothing,
3168+ );
3169+ });
3170+
3171+ testWidgets ('configurable DragTarget hit test behavior' , (WidgetTester tester) async {
3172+ const HitTestBehavior hitTestBehavior = HitTestBehavior .opaque;
3173+
3174+ await tester.pumpWidget (
3175+ const MaterialApp (
3176+ home: Column (
3177+ children: < Widget > [
3178+ LongPressDraggable <int >(
3179+ hitTestBehavior: hitTestBehavior,
3180+ feedback: SizedBox (),
3181+ child: SizedBox (),
3182+ ),
3183+ ],
3184+ ),
3185+ ),
3186+ );
3187+ expect (tester.widget <Listener >(find.descendant (of: find.byType (Column ), matching: find.byType (Listener ))).behavior, hitTestBehavior);
3188+ });
3189+
31043190 // Regression test for https://github.com/flutter/flutter/issues/72483
31053191 testWidgets ('Drag and drop - DragTarget<Object> can accept Draggable<int> data' , (WidgetTester tester) async {
31063192 final List <Object > accepted = < Object > [];
0 commit comments