decode static method

ScenarioNotification? decode(
  1. List<int> bytes
)

bytes back as a notification, or null when they are not one.

Implementation

static ScenarioNotification? decode(List<int> bytes) {
  try {
    var decoded = jsonDecode(utf8.decode(bytes));
    if (decoded is! Map || decoded['body'] is! String) return null;
    return ScenarioNotification(
      body: decoded['body'] as String,
      title: decoded['title'] as String?,
      appName: decoded['appName'] as String?,
    );
  } on FormatException {
    return null;
  }
}