最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Flutter MenuAnchor throws "BoxConstraints forces an infinite width" - Stack Overflow

programmeradmin1浏览0评论

Its happening right at my MenuAnchor:

The relevant error-causing widget was:
    MenuAnchor MenuAnchor

I've seen this error many times, usually means that a height or width is missing. I tried wrapping my MenuAnchor with a SizedBox with a height and width and I tried wrapping the menuChildren with a SizedBox with a height and width and neither fixes the issue. The MenuAnchor is inside of a Column.

Widget build(BuildContext context) {
    return ValueListenableBuilder(
      valueListenable: controller,
      builder: (context, selectedKeys, child) {
        return MenuAnchor(
          controller: controller.menuController,
          alignmentOffset: const Offset(10, 5),
          style: MenuStyle(
            shape: const WidgetStatePropertyAll(LinearBorder()),
            padding: const WidgetStatePropertyAll(EdgeInsets.zero),
            maximumSize: WidgetStatePropertyAll(Size.fromHeight(MediaQuery.of(context).size.height - kToolbarHeight - MediaQuery.of(context).padding.vertical)),
          ),
          key: key,
          menuChildren: [
            ...options.map<Widget>(
              (option) => _DropdownItem<T>(
                selected: controller.isSelected(option.key),
                itemKey: option.key,
                title: option.title,
                onChanged: (key) {
                  controller.toggle(key);
                  onChanged(controller.value);
                },
                showCheckbox: showCheckbox,
              ),
            ),
发布评论

评论列表(0)

  1. 暂无评论