Created
August 24, 2022 09:49
-
-
Save ltOgt/084257d7707cfc629844b2b72e9d6ba4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyMetaData { | |
// Whatever you want | |
} | |
// In the hit test target, e.g. drag target | |
return MyParentTree( | |
child: MetaData( | |
metaData: MyMetaData(...), | |
child: MyChildTree(), | |
), | |
); | |
// In the callback where you hit test; e.g. in the drag update | |
final hitTestRect = getHitTestRectFromSomewhere(); | |
final HitTestResult r = HitTestResult(); | |
WidgetsBinding.instance?.hitTest(r, hitTestRect); | |
for (final HitTestEntry hte in r.path) { | |
final target = hte.target; | |
if (target is RenderMetaData) { | |
final metaData = target.metaData; | |
if (metaData is MyMetaData) { | |
// Do stuff with the found MyMetaData | |
// E.g. trigger the drop to the target | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment