【问题标题】:how to apply gradient color in shaped appbar in flutter? [duplicate]如何在颤动的形状appbar中应用渐变颜色? [复制]
【发布时间】:2021-02-02 01:13:04
【问题描述】:

我已经定制了具有弯曲形状的 Appbar,但是我如何为该区域赋予渐变颜色?

这是我的应用条码

    appBar: AppBar(
    elevation: 5.0,
    backgroundColor: Colors.blue,
    centerTitle: true,
    shape: Cuvedshape(curveheights),
    title: Container(
        margin: EdgeInsets.only(top: 25),
        child: Text("text",
            textAlign: TextAlign.end,
            style: TextStyle(
                letterSpacing: 2,
                fontSize: SizeConfig.safeBlockHorizontal * 8,
                color: Colors.white,
                fontFamily: Constants.FONT_ROBOTO,
                fontWeight: FontWeight.bold))),
  ),

这是我的形状代码

class Cuvedshape extends ContinuousRectangleBorder {
   const Cuvedshape(this.curveheights);
   final double curveheights;

@override
Path getOuterPath(Rect rect, {TextDirection textDirection}) => Path()
..lineTo(0, rect.size.height)
..quadraticBezierTo(rect.size.width / 2,
    rect.size.height + curveheights * 2, rect.size.width, rect.size.height)
..lineTo(rect.size.width, 0)
..close();
}

【问题讨论】:

    标签: android ios flutter dart flutter-layout


    【解决方案1】:

    您不能将渐变颜色应用到 appbar。 您可以创建一个可以放置为 appBar 的自定义小部件。 参考这个答案

    [链接]Adding a Gradient Background to Appbar on Flutter

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-24
      • 2021-12-31
      • 2021-11-18
      • 1970-01-01
      • 1970-01-01
      • 2023-03-29
      • 2022-01-24
      • 1970-01-01
      相关资源
      最近更新 更多