super_enum icon indicating copy to clipboard operation
super_enum copied to clipboard

Ability to specify generated class names.

Open chimon2000 opened this issue 4 years ago • 2 comments

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);
}

chimon2000 avatar Dec 25 '19 16:12 chimon2000

That's a nice idea.

astralstriker avatar Dec 26 '19 05:12 astralstriker

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

ride4sun avatar Jul 14 '20 23:07 ride4sun