fromJson static method

ActionFlow? fromJson(
  1. Object? json
)

Implementation

static ActionFlow? fromJson(Object? json) {
  if (json is! JsonLike) return null;

  final inkwell = NumUtil.toBool(json['inkWell']) ?? true;

  final actions = as$<List<dynamic>>(json['steps'])
          ?.where((e) => e != null || e is! JsonLike)
          .map((e) => ActionFactory.fromJson(e as JsonLike))
          .toList() ??
      [];

  final analyticsData = as$<List<dynamic>>(json['analyticsData'])
          ?.nonNulls
          .cast<JsonLike>()
          .toList() ??
      [];

  // It's possible that events need to be sent, regardless of
  // whether actions are present or not.
  if (analyticsData.isEmpty && actions.isEmpty) return null;

  return ActionFlow(
    actions: actions,
    inkwell: inkwell,
    analyticsData: analyticsData,
  );
}