ActivityEvent.fromString constructor

ActivityEvent.fromString(
  1. String string
)

Create an ActivityEvent based on the string format type,confidence.

Implementation

factory ActivityEvent.fromString(String string) {
  List<String> tokens = string.split(",");
  if (tokens.length < 2) return ActivityEvent.unknown();

  ActivityType type = ActivityType.UNKNOWN;
  if (_activityMap.containsKey(tokens.first)) {
    type = _activityMap[tokens.first]!;
  }
  int conf = int.tryParse(tokens.last)!;

  return ActivityEvent(type, conf);
}