Slide 73
Slide 73 text
© LayerX Inc. 73
3.関⼼範囲の局所化
フォーム種別ごとの
Component
Page
⼊⼒種別ごとの
Component
⼊⼒種別ごとの
Component
⼊⼒種別ごとの
Component
フォーム種別ごとの
Component
⼊⼒種別ごとの
Component
⼊⼒種別ごとの
Component
⼊⼒種別ごとの
Component
バクラクの場合
typedef ForexPaymentAmountFormFieldState = ({
TextEditingController controller,
bool isNegativeAmount,
});
typedef ForexPaymentAmountFormFieldAction = ({
Function(String) onChangedText,
Function(({bool isNegative, String? text}))
onChangedSign,
});
({
ForexPaymentAmountFormFieldState state,
ForexPaymentAmountFormFieldAction action,
}) useForexPaymentAmountFormField({/** */}) {
final controller = useTextEditingController(/** */);
final isNegativeAmount = useState(/** */);
// ...
return (
state: (
controller: controller,
isNegativeAmount: isNegativeAmount.value,
),
action: (
onChangedText: (text) => /** */,
onChangedSign: useCallback(/** */),
)
);
}
AppStateにする必要がないものを切り離して、
依存を最⼩化
class RequestForexPaymentAmountFormField
extends HookConsumerWidget {
const RequestForexPaymentAmountFormField({/** */});
// ...
@override
Widget build(BuildContext context, WidgetRef ref) {
final (
state: (
:controller,
:isNegativeAmount,
),
action: (
:onChangedText,
:onChangedSign,
),
) = useForexPaymentAmountFormField(/** */);
// ...
}
}
flutter_hooksを活⽤