defaultOnReorderForDynamicMap<M extends DynamicMap> static method

Future<M> defaultOnReorderForDynamicMap<M extends DynamicMap>(
  1. int oldPosition,
  2. int newPosition,
  3. M map,
  4. List<M> reordered, {
  5. FutureOr<void> onSaved(
    1. M data
    )?,
  6. String key = "order",
  7. double? defaultOrderValue,
})

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に順番が入れ替わった対象の要素、oldPositionnewPositionに新旧の位置、reorderedに順番が入れ替わった後のリストが渡されます。

onSavedに順番を入れ替えた後に実行するコールバックを指定します。keyには順番の値を記載する要素のキーを指定します。defaultOrderValuekeyに値がなかったときに渡す初期値を指定します。

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,
    );