parseList static method

List<AppInfo> parseList(
  1. dynamic apps
)

Parses a list returned by the native side, skipping invalid entries. Sorted by name.

Implementation

static List<AppInfo> parseList(dynamic apps) {
  if (apps == null || apps is! List || apps.isEmpty) return [];
  final List<AppInfo> appInfoList = apps
      .where(
        (element) =>
            element is Map &&
            element.containsKey("name") &&
            element.containsKey("package_name"),
      )
      .map(AppInfo.create)
      .toList()
    ..sort((a, b) => a.name.compareTo(b.name));
  return appInfoList;
}