class SCDialogQueue {
  static final SCDialogQueue _a = SCDialogQueue._();

  factory SCDialogQueue() => _a;

  SCDialogQueue._();

  final List<Function> _l = [];
  bool _b = false;

  // 添加弹框
  void add(Function showDialogFunc) {
    _l.add(showDialogFunc);
    _n();
  }

  // 弹框关闭
  void dismiss() {
    _b = false;
    _n();
  }

  // 清空
  void clear() {
    _l.clear();
    _b = false;
  }

  // 尝试显示下一个
  void _n() {
    if (_b || _l.isEmpty) return;

    _b = true;
    final func = _l.removeAt(0);
    func();
  }
}
