0

当我使用 Freezed 生成密封类时,如何向密封类添加方法?

例如:

import 'package:freezed_annotation/freezed_annotation.dart';
part 'student_state.freezed.dart';

@freezed
abstract class StudentState with _$StudentState {
  factory StudentState.loading() = StudentFetchInProgress;
  factory StudentState.success(List<int> studentIds) = StudentFetchSuccess;
}

我想向 StudentFetchSuccess 类添加一个函数。我不知道它是否可能,但即使你告诉我不可能,我也会很感激。

谢谢您的帮助 :)

4

0 回答 0