How to perform equality check? #730
Answered
by
rrousselGit
2shrestha22
asked this question in
Q&A
-
This test fails. Would anyone tell me about what I am doing wrong? void main() {
late SubscriptionPlan subscriptionPlan;
setUp(() {
subscriptionPlan = SubscriptionPlan.trial();
});
test(
'isTrial works',
() {
expect(subscriptionPlan.isTrial(), true);
},
);
} @freezed
class SubscriptionPlan with _$SubscriptionPlan {
const SubscriptionPlan._();
/// Plans that user can subscribe to
const factory SubscriptionPlan({
required ProductDetails productDetails,
}) = _SubscriptionPlan;
factory SubscriptionPlan.trial() => SubscriptionPlan(
productDetails: ProductDetails(
id: '',
title: '7 day free trial',
description: 'free',
price: 'free',
rawPrice: 0,
currencyCode: '',
),
);
String get id => productDetails.id;
String get title => productDetails.title;
String get price => productDetails.price;
String get description => productDetails.description;
bool isTrial() => this == SubscriptionPlan.trial();
} class ProductDetails {
ProductDetails({
required this.id,
required this.title,
required this.description,
required this.price,
required this.rawPrice,
required this.currencyCode,
this.currencySymbol = '',
});
final String id;
final String title;
final String description;
final String price;
final double rawPrice;
final String currencyCode;
final String currencySymbol;
} |
Beta Was this translation helpful? Give feedback.
Answered by
rrousselGit
Aug 8, 2022
Replies: 1 comment 5 replies
-
Your Product Detail class does not override == |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
2shrestha22
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your Product Detail class does not override ==