Skip to content
This repository was archived by the owner on Jun 25, 2019. It is now read-only.
This repository was archived by the owner on Jun 25, 2019. It is now read-only.

Event handlers in example not firing due to exception #45

@devantic

Description

@devantic

This code in the example throws an exception on the .listens. This effectively disables all the event handlers except the one that throws the exception, i.e the first one. Here .listen((location ... fails which means the following aren't executed. If I comment it out, the exception is thrown on the next.

If I wrap each in a try-catch to ignore the errors the handlers still work. That's my work-around for now.

    sub = mapView.onLocationUpdated
        .listen((location) => print("Location updated $location"));
    compositeSubscription.add(sub);

    sub = mapView.onTouchAnnotation
        .listen((annotation) => print("annotation tapped"));
    compositeSubscription.add(sub);

    sub = mapView.onMapTapped
        .listen((location) => print("Touched location $location"));
    compositeSubscription.add(sub);

    sub = mapView.onCameraChanged.listen((cameraPosition) =>
        this.setState(() => this.cameraPosition = cameraPosition));
    compositeSubscription.add(sub);

    sub = mapView.onToolbarAction.listen((id) {
      if (id == 1) {
        _handleDismiss();
      }
    });
    compositeSubscription.add(sub);

    sub = mapView.onInfoWindowTapped.listen((marker) {
      print("Info Window Tapped for ${marker.title}");
    });
    compositeSubscription.add(sub);
  }
I/flutter (10026): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter (10026): The following assertion was thrown while handling a gesture:
I/flutter (10026): type '_BroadcastSubscription<Location>' is not a subtype of type 'StreamSubscription<Null>' where
I/flutter (10026):   _BroadcastSubscription is from dart:async
I/flutter (10026):   Location is from package:map_view/location.dart
I/flutter (10026):   StreamSubscription is from dart:async
I/flutter (10026):   Null is from dart:core
I/flutter (10026): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (10026): more information in this error message to help you determine and fix the underlying cause.
I/flutter (10026): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (10026):   https://github.com/flutter/flutter/issues/new
I/flutter (10026): When the exception was thrown, this was the stack:
I/flutter (10026): #0      _MyAppState.showMap (file:///C:/Users/Paul/Documents/flutter/map_view_example/lib/main.dart:125:10)
I/flutter (10026): #1      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:490:14)
I/flutter (10026): #2      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:545:30)
I/flutter (10026): #3      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
I/flutter (10026): #4      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:161:9)
I/flutter (10026): #5      TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:94:7)
I/flutter (10026): #6      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
I/flutter (10026): #7      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
I/flutter (10026): #8      PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
I/flutter (10026): #9      _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19)
I/flutter (10026): #10     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
I/flutter (10026): #11     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
I/flutter (10026): #12     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
I/flutter (10026): #13     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
I/flutter (10026): #14     _invoke1 (dart:ui/hooks.dart:134:13)
I/flutter (10026): #15     _dispatchPointerDataPacket (dart:ui/hooks.dart:91:5)
I/flutter (10026): Handler: onTap
I/flutter (10026): Recognizer:
I/flutter (10026):   TapGestureRecognizer#39b2f(debugOwner: GestureDetector, state: possible, won arena, finalPosition:
I/flutter (10026):   Offset(283.7, 182.2), sent tap down)
I/flutter (10026): ════════════════════════════════════════════════════════════════════════════════════════════════════

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions