sendToBack static method

bool sendToBack(
  1. String id, {
  2. int step = 1,
})

Sends an active modal/snackbar below all current layers.

Implementation

static bool sendToBack(String id, {int step = 1}) {
  final current = getStackLevel(id);
  if (current == null) return false;

  final levels = <int>[];
  if (_sheetController.state != null) {
    levels.add(_sheetController.state!.stackLevel);
  }
  if (_dialogController.state != null) {
    levels.add(_dialogController.state!.stackLevel);
  }
  if (_activeModalController.state != null) {
    levels.add(_activeModalController.state!.stackLevel);
  }
  for (final queue in _snackbarQueueNotifier.state.values) {
    for (final content in queue) {
      levels.add(content.stackLevel);
    }
  }

  final bottom = levels.isEmpty ? current : levels.reduce(min);
  return setStackLevel(id, bottom - max(step, 1));
}