- Introduced MatchRepository and MatchResultsViewModel to handle match data. - Replaced task-related code with match-related functionality in the app. - Added match results view and updated navigation to reflect changes. - Removed task-related models, services, and view models. - Added JSON data for match results and integrated it into the app. - Updated tests to validate match results loading and UI behavior.
18 lines
558 B
Dart
18 lines
558 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/services.dart';
|
|
import '../../domain/models/hockey_game.dart';
|
|
|
|
class MatchRepository {
|
|
MatchRepository({AssetBundle? bundle}) : _bundle = bundle ?? rootBundle;
|
|
|
|
final AssetBundle _bundle;
|
|
|
|
Future<List<Match>> loadMatches() async {
|
|
final contents = await _bundle.loadString('lib/data/results.json');
|
|
final data = jsonDecode(contents) as Map<String, dynamic>;
|
|
return (data['games'] as List<dynamic>)
|
|
.map((game) => Match.fromJson(game as Map<String, dynamic>))
|
|
.toList();
|
|
}
|
|
} |