getState method

Future<SessionState> getState()
override

Returns the state of the session.

Implementation

Future<SessionState> getState() async {
  try {
    return _platform
        .abstractSessionGetState(this.getSessionId())
        .then((state) {
      switch (state) {
        case 0:
          return SessionState.created;
        case 1:
          return SessionState.running;
        case 2:
          return SessionState.failed;
        case 3:
        default:
          return SessionState.completed;
      }
    });
  } on PlatformException catch (e, stack) {
    print("Plugin getState error: ${e.message}");
    return Future.error("getState failed.", stack);
  }
}