super_enum
super_enum copied to clipboard
Ability to specify generated class names.
Would like the ability to specify the name to use when computing sealed class. This would remove collisions when creating similarly named classes. See the following example taken from sealed_unions_generator
@Seal('WeatherState')
abstract class WeatherModel {
@Sealed()
void initial();
@Sealed()
void loading();
@Sealed()
void loaded(int temperature);
}
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'weather_model.dart';
// **************************************************************************
// SealedUnionsGenerator
// **************************************************************************
class WeatherState extends Union3Impl<WeatherStateInitial, WeatherStateLoading,
WeatherStateLoaded> {
static final Triplet<WeatherStateInitial, WeatherStateLoading,
WeatherStateLoaded> _factory =
const Triplet<WeatherStateInitial, WeatherStateLoading,
WeatherStateLoaded>();
WeatherState._(
Union3<WeatherStateInitial, WeatherStateLoading, WeatherStateLoaded>
union)
: super(union);
factory WeatherState.initial() =>
WeatherState._(_factory.first(WeatherStateInitial()));
factory WeatherState.loading() =>
WeatherState._(_factory.second(WeatherStateLoading()));
factory WeatherState.loaded(int temperature) =>
WeatherState._(_factory.third(WeatherStateLoaded(temperature)));
}
class WeatherStateInitial {
WeatherStateInitial();
}
class WeatherStateLoading {
WeatherStateLoading();
}
class WeatherStateLoaded {
final int temperature;
WeatherStateLoaded(this.temperature);
}
That's a nice idea.
I run into the same problem - is there a ETA for a fix for that. This seemed to be a common problem when you create multiple blocs. I did run into it that problem after just one day by using Start
and Stop
in multiple bloc's.
@xsahil03x Very cool package by the way - Thanks