3

此问题类型“SliverAppBar”不是“PreferredSizeWidget”FLUTTER 问题类型的子类型。尝试在FLUTTER 中使用 SilverAppBar创建浮动工具栏时出现。

class AppTheme {
  setAppBar(context, String title) {
    return new AppBa(
      floating: true,
      pinned: true,
      title: Text(title,
          style: TextStyle(color: Colors.white),
          textDirection: TextDirection.ltr),
      flexibleSpace: Container(
        decoration: new BoxDecoration(
          gradient: new LinearGradient(
              colors: [
                hexToColor(themeColor1),
                hexToColor(themeColor2),
              ],
              begin: const FractionalOffset(0.0, 0.0),
              end: const FractionalOffset(1.0, 0.0),
              stops: [0.0, 1.0],
              tileMode: TileMode.clamp),
        ),
      ),
    );
  }
}
4

1 回答 1

1

你应该SliverAppBar用一个CustomScrollView

CustomScrollView(
   slivers: <Widget>[
      SliverAppBar(
        ...
      ),
      ...
   ]
);
于 2020-08-14T22:19:12.053 回答