上下文菜单按钮项!如何更改 ContextMenuButtonItem 颤动的样式。复制/粘贴按钮工具栏颤动

问题描述 投票:0回答:1

如何更改 ContextMenuButtonItem 的样式 我不想为了更改 Android 按钮的 2 种样式而重做整个功能。 也许主题数据中这些按钮的样式发生了变化?

 TextField(
                contextMenuBuilder: (context, editableTextState) {
                 
                  final value = editableTextState.textEditingValue;
                  final List<ContextMenuButtonItem> buttonItems = [
                    ContextMenuButtonItem(
                      onPressed: () {},
                      type: ContextMenuButtonType.custom,
                    )
                  ];

                  return AdaptiveTextSelectionToolbar.buttonItems(
                      buttonItems: buttonItems, anchors: editableTextState.contextMenuAnchors);
                },
)

我创建了一个单独的类,在其中制作了自己的小部件。但我无法连接 List 和 List

class _MyContextMenu extends StatelessWidget {
  const _MyContextMenu({
    required this.anchor,
    required this.children,
    required this.contextMenuButtonItems,
  });

  final Offset anchor;
  final List<Widget> children;
  final List<ContextMenuButtonItem> contextMenuButtonItems;

  @override
  Widget build(BuildContext context) {
    contextMenuButtonItems.insert(0, Container() as ContextMenuButtonItem);
    return Stack(
      children: [
        Positioned(
          height: 34,
          top: anchor.dy + 38,
          left: anchor.dx - 24,
          child: Card(
            shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)),
            child: Center(
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                  ...children,
                  ...contextMenuButtonItems.map((item) => YourWidget(item)),
                ],
              ),
            ),
          ),
        ),
      ],
    );
  }
}
flutter styles textfield toolbar copy-paste
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.