6thsolution / dart_sealed

Dart and Flutter sealed class generator and annotations, with match methods and other utilities. There is also super_enum compatible API.
https://pub.dev/packages/sealed_annotations
MIT License
17 stars 9 forks source link

How can I convert super enums to this package #17

Open ride4sun opened 1 year ago

ride4sun commented 1 year ago

I have this super_enum and the advise was to convert this to this package. I am wondering how all this will convert? Any help is appreciated...

import 'package:super_enum/super_enum.dart';

part 'emission_test_bloc_state.super.dart';

@superEnum
enum _EmissionTestBlocState {
  @object
  Disconnected,
  @object
  NoVinFailure,

  @object
  NoInternet,

  @Data(fields: [
    DataField<String>('vin'),
  ])
  Waiting,
  @Data(fields: [
    DataField<String>('request'),
  ])
  RequestMILStatus,
  @Data(fields: [
    DataField<String>('request'),
  ])
  RequestDTC,
  @object
  RequestRedinessMonitor,
  @Data(fields: [
    DataField<dynamic>('dtcs'),
    DataField<dynamic>('status'),
  ])
  TestFaliure,
  @Data(fields: [
    DataField<String>('message'),
    DataField<dynamic>('status'),
  ])
  TestPassed,
  @Data(fields: [
    DataField<dynamic>('status'),
  ])
  NotCompleted,
  @Data(fields: [
    DataField<String>('request'),
  ])
  RequestClearDTC,
  @object
  ErrorCodesCleared,
}
FatulM commented 7 months ago

Hi, The last version supporting super_enum was 1.4.0. Please check it's docs and use it if it is possible ... Also It would generate dart_sealed code in comments, which you could use to migrate your code completely from super_enum to dart_sealed.

see: doc

for an example see: weather.dart weather.super.dart

Afterwards, from version 1.5, I have droped support for super_enum. But I think making a workable code is very easy, from migrating code in version 1.4 to the last version.