setBatch method

void setBatch({
  1. List<(String, String)> stringItems = const <(String, String)>[],
  2. List<(String, bool)> boolItems = const <(String, bool)>[],
  3. List<(String, int)> intItems = const <(String, int)>[],
  4. List<(String, int)> largeIntItems = const <(String, int)>[],
  5. List<(String, double)> doubleItems = const <(String, double)>[],
})

Store multiple key-value pairs of various types in a single operation.

This method allows setting multiple values of different types (string, bool, int, large int, double) at once, which can be more efficient than multiple individual calls.

Parameters

  • stringItems: List of key-value pairs where the value is a String.
  • boolItems: List of key-value pairs where the value is a `bool
  • intItems: List of key-value pairs where the value is a 32-bit int.
  • largeIntItems: List of key-value pairs where the value is a 64-bit int.
  • doubleItems: List of key-value pairs where the value is a double.

Also see:

  • getBatch: to retrieve multiple values of various types in a single operation.

Implementation

void setBatch({
  List<(String, String)> stringItems = const <(String, String)>[],
  List<(String, bool)> boolItems = const <(String, bool)>[],
  List<(String, int)> intItems = const <(String, int)>[],
  List<(String, int)> largeIntItems = const <(String, int)>[],
  List<(String, double)> doubleItems = const <(String, double)>[],
}) {
  final List<Pair<String, String>> stringPairs = stringItems
      .map(
        (final (String, String) item) =>
            Pair<String, String>(item.$1, item.$2),
      )
      .toList();
  final List<Pair<String, bool>> boolPairs = boolItems
      .map(
        (final (String, bool) item) => Pair<String, bool>(item.$1, item.$2),
      )
      .toList();
  final List<Pair<String, int>> intPairs = intItems
      .map((final (String, int) item) => Pair<String, int>(item.$1, item.$2))
      .toList();
  final List<Pair<String, int>> largeIntPairs = largeIntItems
      .map((final (String, int) item) => Pair<String, int>(item.$1, item.$2))
      .toList();
  final List<Pair<String, double>> doublePairs = doubleItems
      .map(
        (final (String, double) item) =>
            Pair<String, double>(item.$1, item.$2),
      )
      .toList();

  objectMethod(
    pointerId,
    'SettingsService',
    'setBatch',
    args: <String, dynamic>{
      'stringValues': <String, dynamic>{'values': stringPairs},
      'boolValues': <String, dynamic>{'values': boolPairs},
      'intValues': <String, dynamic>{'values': intPairs},
      'largeIntValues': <String, dynamic>{'values': largeIntPairs},
      'doubleValues': <String, dynamic>{'values': doublePairs},
    },
  );
}