Open dany2709 opened 2 years ago
I have been trying to generate the mapper.g.dart after configuring everything in the classes and I always get the same error.
flutter pub run build_runner build --delete-conflicting-outputs --verbose
[SEVERE] simple_json:simple_json on lib/$lib$: FormatException: Unexpected extension byte (at offset 97) dart:async _rootRunUnary package:build_resolvers/src/build_asset_uri_resolver.dart 120:23 BuildAssetUriResolver._updateCachedAssetState package:build_resolvers/src/build_asset_uri_resolver.dart 75:16 BuildAssetUriResolver.performResolve package:build_resolvers/src/resolver.dart 128:11 PerActionResolver._resolveIfNecessary.<fn> package:pool/pool.dart 127:14 Pool.withResource package:build_resolvers/src/resolver.dart 91:5 PerActionResolver.isLibrary package:simple_json/src/json_mapper_builder.dart 42:12 JsonMapperBuilder.build
SessionModel.dart
import 'package:project/core/di/di.dart'; import 'package:project/core/service/storage_service.dart'; import 'package:project/features/authentication/data/models/user_model.dart'; import 'package:project/features/authentication/domain/entities/session_entity.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:simple_json_mapper/simple_json_mapper.dart'; part 'session_model.g.dart'; @JsonObject() @JsonSerializable() class SessionModel extends Session { const SessionModel({ required this.token, required this.tokenType, required this.realm, required this.user, }) : super( token: token, tokenType: tokenType, realm: realm, user: user, ); factory SessionModel.fromJson(Map<String, dynamic> json) => _$SessionModelFromJson(json); Map<String, dynamic> toJson() => _$SessionModelToJson(this); // save instance on SecureStorage @override Future<void> save() async { return getIt<Storage>().write<Session>(key: Session.key, obj: this); } // @JsonProperty(name: 'access_token') @JsonProperty(name: 'access_token') @JsonKey(name: 'access_token') final String token; @JsonProperty(name: 'token_type') @JsonKey(name: 'token_type') final String tokenType; @JsonProperty(name: 'realm') @JsonKey(name: 'realm') final String realm; @JsonProperty(name: 'user') @JsonKey(name: 'user') final UserModel user; @override List<Object?> get props => [ token, tokenType, realm, user, ]; }
I am using json_annotation to generate fromJson and toJson, I don't think that is what is generating the error. Any idea what I might be doing wrong?
I have been trying to generate the mapper.g.dart after configuring everything in the classes and I always get the same error.
flutter pub run build_runner build --delete-conflicting-outputs --verbose
SessionModel.dart
I am using json_annotation to generate fromJson and toJson, I don't think that is what is generating the error. Any idea what I might be doing wrong?