AppConfig.fromMap constructor

AppConfig.fromMap(
  1. Map<String, dynamic> map
)

Creates an AppConfig from a map (typically from a TOML document).

The map should have a github section with a repos array:

[github]
repos = [
  { name = "Repo Name", github_url = "https://github.com/owner/repo" }
]

Only valid repository configurations (with non-empty name and URL) are included.

Implementation

factory AppConfig.fromMap(Map<String, dynamic> map) {
  final githubSection = map['github'] as Map<String, dynamic>? ?? {};
  final reposList = githubSection['repos'] as List<dynamic>? ?? [];

  final repos = reposList
      .map((item) => GitHubRepoConfig.fromMap(item as Map<String, dynamic>))
      .where((repo) => repo.isValid)
      .toList();

  return AppConfig(repos: repos);
}