import 'package:json_annotation/json_annotation.dart';
import 'package:netrain_flutter_app/zhangfeng/Network/SaveModel.dart';

part 'UserModel.g.dart';

@JsonSerializable()

class UserModel{
  static UserModel sharedModelInstance_;

  final token;
  final header;
  final tokenHead;

  UserModel(this.token, this.header, this.tokenHead);

  factory UserModel.fromJson(Map<String, dynamic> json) => _$UserModelFromJson(json);
  Map<String, dynamic> toJson() => _$UserModelToJson(this);

  static UserModel getModel(){
    if(sharedModelInstance_ == null){
        Map json = SaveModel.getModel('UserModel');
        if(json != null){
          sharedModelInstance_ = new UserModel.fromJson(json);
        }
    }
    return sharedModelInstance_;
  }

  static removeModel() {
    SaveModel.removeModel('UserModel');
    sharedModelInstance_ = null;
  }

  static saveModel(UserModel userModel){
    sharedModelInstance_ = userModel;
    SaveModel.saveModel(userModel,'UserModel');
  }
}
