defaultOnReorderForDynamicMap<M extends DynamicMap> static method
Method to define ReorderableListBuilder.onReorder when the list data consists of DynamicMap.
The elements to be reordered are passed to map
, oldPosition
and newPosition
are the old and new positions, and reordered
is the list after the reordering.
Specify the callback to be executed after reordering in onSaved
. Specify the key of the element for which the order value is to be entered in key
. Specify the initial value to be passed to defaultOrderValue
if key
has no value.
リストのデータがDynamicMapで構成されている場合のReorderableListBuilder.onReorderを定義するためのメソッド。
map
に順番が入れ替わった対象の要素、oldPosition
、newPosition
に新旧の位置、reordered
に順番が入れ替わった後のリストが渡されます。
onSaved
に順番を入れ替えた後に実行するコールバックを指定します。key
には順番の値を記載する要素のキーを指定します。defaultOrderValue
にkey
に値がなかったときに渡す初期値を指定します。
Implementation
static Future<M> defaultOnReorderForDynamicMap<M extends DynamicMap>(
int oldPosition,
int newPosition,
M map,
List<M> reordered, {
FutureOr<void> Function(M data)? onSaved,
String key = "order",
double? defaultOrderValue,
}) =>
defaultOnReorder(
oldPosition,
newPosition,
map,
reordered,
onRetrieve: (map) => map.get(key, 0.0),
onUpdate: (map, order) async {
map[key] = order;
await onSaved?.call(map);
},
defaultOrderValue: defaultOrderValue,
);