2

I am trying to use a type of Option<Either<T,T> and want to set this to a none() but this fails the error Invalid constant value.dart(invalid_constant).

How can I set a Option to a none or undefined state.

@freezed
abstract class InvitationsState with _$InvitationsState {
  const factory InvitationsState({
    @required String email,
    @required bool isSubmitting,
    @required bool userAlreadyInvited,
    Option<Either<IRepositoryFailure, Stream<QuerySnapshot>>> snapshotOrFailure,
  }) = _InvitationsState;

  factory InvitationsState.initial() => const InvitationsState(
        email: "",
        isSubmitting: false,
        userAlreadyInvited: false,
        snapshotOrFailure: none(),
      );
}
HII
  • 3,420
  • 1
  • 14
  • 35
Mark
  • 7,507
  • 12
  • 52
  • 88
  • you are getting an error on this line "snapshotOrFailure: none()," ? – HII Apr 23 '20 at 13:26
  • Exactly. Not sure why, but I am using in this project dartz the first time. – Mark Apr 23 '20 at 13:27
  • that's weird you are doing nothing wrong in the snippet you provided, maybe code generation is not working correctly, try flutter packages pub run build_runner clean then try generation again and tell me result – HII Apr 23 '20 at 13:28
  • 1
    Good to know that I am not completely off the track. I found the error. I removed the `const` Keyword from the `const` from the `initial()` function. Now I don't show an error. Facepalm :) – Mark Apr 23 '20 at 13:45

0 Answers0