0

I'am trying to add freezed in my State file in order to write a test. Can somebody help me to do so? I'll appreciate any help!

part of 'exchange_cubit.dart';



@immutable
class ExchangeState {
  const ExchangeState(
      {this.model, this.status = Status.initial, this.errorMessage});
  final ExchangeModel? model;
  final Status status;
  final String? errorMessage;
}

My problem is to assign a @Default value for my Model which doesn't return a list of documents but a single document. So I made my Model non - default to get rid of the errors like below

part of 'exchange_cubit.dart';

@freezed
class ExchangeState with _$ExchangeState {
  ExchangeState._();
  factory ExchangeState({
     ExchangeModel? model,
    @Default(Status.initial) Status? status,
    @Default('') String? errorMessage,
  }) = _ExchangeState;
}

But I'm assuming that's not a proper way to do so. If it returned a list of documents I would assign it an empty list "[]". I don't know how to do it with a single document though

asiak1999
  • 13
  • 3

0 Answers0