showWidget<T> method

  1. @override
Future<T?> showWidget<T>(
  1. Widget widget, {
  2. Widget? background,
  3. int level = 0,
  4. bool dragAble = false,
  5. double? top,
  6. double? left,
  7. double? right,
  8. double? bottom,
  9. bool indexAble = false,
  10. bool edgeAble = false,
})
override

Implementation

@override
//添加时,是否需要level
Future<T?> showWidget<T>(
  Widget widget, {
  Widget? background,
  int level = 0,
  bool dragAble = false,
  double? top,
  double? left,
  double? right,
  double? bottom,
  bool indexAble = false,
  bool edgeAble = false,
}) {
  List<Widget> group = const [];

  Widget targetkey = widget;
  if (widget is PositionableWidget) {
    targetkey = widget.child;
    group = [widget];
  } else if (dragAble == true ||
      top != null ||
      left != null ||
      right != null ||
      bottom != null ||
      indexAble == true ||
      edgeAble == true) {
    widget = DecoratedBox(
      decoration: BoxDecoration(
        color: Colors.white,
        boxShadow: [
          BoxShadow(
            color: Colors.black.withValues(alpha: 0.5),
            blurRadius: 5,
            spreadRadius: 2,
          ),
        ],
      ),
      child: widget,
    );
    widget = PositionableWidget(
      dragAble: dragAble,
      top: top,
      left: left,
      right: right,
      bottom: bottom,
      indexAble: indexAble,
      edgeAble: edgeAble,
      child: widget,
    );
    group = [widget];
  }
  if (background != null) {
    group = [widget, background];
    children.add(background);
    levels.add(level);
  }
  //此处需要根据level排序;
  children.add(widget);
  levels.add(level);
  update();
  if (group.isNotEmpty) {
    childMap[targetkey] = group;
  }
  if (T != dynamic) {
    var a = Completer<T?>();
    results[targetkey] = a;
    return a.future;
  }
  return Future.value();
}