墨well不适用于带装饰的容器

时间:2020-03-17 08:35:27

标签: flutter flutter-layout

如何在使用装饰的容器中正确使用墨水池小部件

enter image description here

这是代码:

Widget option({String option}) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
      child: InkWell(
        borderRadius: BorderRadius.circular(20),
        onTap: (){},

              child: Container(
            alignment: Alignment.centerLeft,
            decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: Theme.of(context).disabledColor),
            child: Padding(
                padding: const EdgeInsets.all(18.0),
                child: Text(
                  option,
                  style: Theme.of(context).textTheme.display2,
                ),
            )),
      ),
    );
  }

1 个答案:

答案 0 :(得分:0)

此代码可以正常工作:

Widget option({String option}) {
    Color disabledColor = Theme.of(context).disabledColor;

    return Padding(
      padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
      child: new Container(
        decoration: BoxDecoration(
          borderRadius: new BorderRadius.all(new Radius.circular(20.0)),
          color: disabledColor,
        ),
        child: Material(
          color: Colors.transparent,
          child: InkWell(
            borderRadius: BorderRadius.circular(20.0),
            splashColor: Theme.of(context).primaryColorDark,
            onTap: () {},
            child: Container(
              alignment: Alignment.centerLeft,
              padding: EdgeInsets.all(16.0),
              child: Text(option, style: Theme.of(context).textTheme.display2),
            ),
          ),
        ),
      ),
    );
  }