如何在对话框上设置侧边颜色

huangapple go评论71阅读模式
英文:

how to make side color on dialog

问题

你们知道如何在对话框上添加类似下图的侧边颜色吗?

如何在对话框上设置侧边颜色

如果你想知道我的代码,我在这里附上它:

Future<T?> showCustomDialog<T>(BuildContext context) {
    return showDialog<T>(
      context: context,
      builder: (context) => Dialog(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(16),
        ),
        child: this,
      ),
    );
  }

只需假设这个小部件位于子组件中。

英文:

Do you guys know how to give side color on dialog like picture below.

如何在对话框上设置侧边颜色

If you want to know my code, here I attach it:

Future&lt;T?&gt; showCustomDialog&lt;T&gt;(BuildContext context) {
    return showDialog&lt;T&gt;(
      context: context,
      builder: (context) =&gt; Dialog(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(16),
        ),
        child: this,
      ),
    );
  }

Just assume the widget is in the child.

答案1

得分: 1

你可以尝试这样做:

showDialog(
  context: context,
  builder: (BuildContext context) {
    return Dialog(
      clipBehavior: Clip.antiAlias,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(16),
      ),
      child: Column(
        children: [
          Container(
            color: Colors.green,
            width: double.infinity,
            height: 10,
          ),
        ],
      ),
    );
  }
);

如何在对话框上设置侧边颜色

英文:

You can try this:

showDialog(
  context: context,
  builder: (BuildContext context) {
    return Dialog(
      clipBehavior: Clip.antiAlias,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(16),
      ),
      child: Column(
        children: [
          Container(
            color: Colors.green,
            width: double.infinity,
            height: 10,
          ),
        ],
      ),
    );
  });

如何在对话框上设置侧边颜色

huangapple
  • 本文由 发表于 2023年1月9日 14:25:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/75053798.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定