Verifying if GestureBinding is ready and if not, throwing a meaningful error

This commit is contained in:
Erick Zanardo
2019-02-01 12:53:32 -02:00
parent 67141af18b
commit a80218d1ed
2 changed files with 6 additions and 1 deletions

View File

@ -56,6 +56,10 @@ class Util {
///
/// Use this in order to get it to work in case your app also contains other widgets.
void addGestureRecognizer(GestureRecognizer recognizer) {
if (GestureBinding.instance == null) {
throw new Exception("GestureBinding is not initialized yet, this probably happened because addGestureRecognizer was called before the runApp method");
}
GestureBinding.instance.pointerRouter.addGlobalRoute((PointerEvent e) {
if (e is PointerDownEvent) {
recognizer.addPointer(e);