Let's say I have an enum that defines the sorting mode in the UI
假设我有一个枚举,它定义了UI中的排序模式
enum SortType {
name,
date,
location,
}
I would like to have a riverpod Notifier that stores the current sorting mode
我想要一个存储当前排序模式的RiverPod通告程序
@riverpod
class SortType extends _$SortType {
@override
SortType build() {
return SortType.date;
}
void switchType(SortType type) {
state = type;
}
}
This causes a rather silly naming conflict. Of course, I could not name the enum and the riverpod Class the same way but I would like the enum to keep the intuitive name and the notifierProvider to also have a nice autogenerated name that is sortTypeProvider
这导致了一个相当愚蠢的命名冲突。当然,我不能用相同的方式命名enum和riverpod Class,但我希望enum保留直观的名称,并且notifierProvider也有一个很好的自动生成的名称sortTypeProvider
What is the best way to achieve this?
实现这一目标的最佳方式是什么?
更多回答
I'd call the enum SortingMode, and the provider CurrentSortingMode
我会调用枚举SortingMode和提供程序CurrentSortingMode
优秀答案推荐
我是一名优秀的程序员,十分优秀!