LCOV - code coverage report
Current view: top level - lib/challenges/models - challenge_model.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 10 10.0 %
Date: 2022-03-03 12:16:04 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:freezed_annotation/freezed_annotation.dart';
       2             : import 'package:ws_game_server_types/ws_game_server_types.dart';
       3             : 
       4             : import 'challenge_task_model.dart';
       5             : 
       6             : typedef ChallengeModelFromJson = ChallengeModel Function(JsonMap json);
       7             : 
       8             : mixin ChallengeModel {
       9             :   JsonMap toJson();
      10             :   String get typeName;
      11             :   List<ChallengeTaskModel> get tasks;
      12             : }
      13             : 
      14           0 : final _fromJsonMap = <String, ChallengeModelFromJson>{};
      15             : 
      16             : class ChallengeModelConverter
      17             :     implements JsonConverter<ChallengeModel?, JsonMap> {
      18           6 :   const ChallengeModelConverter();
      19             : 
      20           0 :   @override
      21             :   ChallengeModel fromJson(JsonMap json) {
      22           0 :     final fromJson = _fromJsonMap[json['type']];
      23             :     if (fromJson == null) {
      24           0 :       throw Exception('No entry for \'type\' ${json['type']}');
      25             :     }
      26           0 :     return fromJson(json);
      27             :   }
      28             : 
      29           0 :   @override
      30             :   JsonMap toJson(ChallengeModel? data) {
      31           0 :     final json = data?.toJson();
      32           0 :     json?['type'] = data?.typeName;
      33           0 :     return json ?? {};
      34             :   }
      35             : }

Generated by: LCOV version 1.13