Skip to content

Instantly share code, notes, and snippets.

@daiki1003
Created March 16, 2023 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daiki1003/509a659037e5a7daefc4ab118aa40e88 to your computer and use it in GitHub Desktop.
Save daiki1003/509a659037e5a7daefc4ab118aa40e88 to your computer and use it in GitHub Desktop.
// OK
@Freezed(unionKey: 'type')
class FlightPlan with _$FlightPlan {
factory FlightPlan.first({
required String type,
required String monitorMaker,
required bool baggageDeliveryAvailable,
}) = FirstClassFlightPlan;
factory FlightPlan.economy({
required String type,
required String beefOrChicken,
}) = EconomyClassFlightPlan;
factory FlightPlan.fromJson(Map<String, dynamic> json) =>
_$FlightPlanFromJson(json);
}
// NG
@Freezed(unionKey: 'plan_type')
class FlightPlan with _$FlightPlan {
factory FlightPlan.first({
required String planType,
required String monitorMaker,
required bool baggageDeliveryAvailable,
}) = FirstClassFlightPlan;
factory FlightPlan.economy({
required String planType,
required String beefOrChicken,
}) = EconomyClassFlightPlan;
factory FlightPlan.fromJson(Map<String, dynamic> json) =>
_$FlightPlanFromJson(json);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment