Slide 15
Slide 15 text
15
© LayerX Inc.
UIをSealedクラスを⽤いた形に更新
Sealedクラスを使う
class PaymentAmountField extends StatelessWidget {
const PaymentAmountField({
required this.inputValue,
super.key,
});
final InputValue inputValue;
@override
Widget build(BuildContext context) {
return SampleTextField(
amount: inputValue.amount,
isFixed: inputValue.isFixed,
borderColor: inputValue.borderColor,
showIcon: inputValue.showIcon,
);
}
}
extension on InputValue {
bool get isFixed => switch (this) {
ManualValue() => false,
OcrCompletedValue() => false,
SystemFixedValue() => true,
};
bool get showIcon => switch (this) {
ManualValue() => false,
OcrCompletedValue() => true,
SystemFixedValue() => false,
};
Color get borderColor => switch (this) {
ManualValue() => Colors.blue,
OcrCompletedValue() => Colors.grey,
SystemFixedValue() => Colors.grey,
};
}
わかりやすやのためにor句は未使⽤です