Skip to content

Commit

Permalink
fix: Added select functionality to FormRef.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Aug 22, 2023
1 parent 0090cb8 commit 9f3430a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/masamune/lib/form/form_scoped_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ class FormRef implements WidgetRef {

@override
WidgetScopedValueRef get widget => _widgetRef.widget;

/// When a value is being added to a form, [onAdd] is executed; when editing, [onEdit] is executed.
///
/// フォームに値を追加しているときは[onAdd]が実行され、編集しているときは[onEdit]が実行されます。
T? select<T>({T Function()? onAdd, T Function(String? editId)? onEdit}) {
if (isAdding) {
return onAdd?.call();
} else {
return onEdit?.call(editId);
}
}
}

/// Abstract class to implement the View portion of the form widget used to both add new and edit existing forms.
Expand Down

0 comments on commit 9f3430a

Please sign in to comment.