type 'SliverAppBar' is not a subtype of type 'PreferredSizeWidget' FLUTTER issue

2,969

You should wrap your SliverAppBar with a CustomScrollView:

CustomScrollView(
   slivers: <Widget>[
      SliverAppBar(
        ...
      ),
      ...
   ]
);
Share:
2,969
jazzbpn
Author by

jazzbpn

With 6+ years of experience, I have developed many iOS/android applications in different context, professional and oldest passion for computer programming began very early in my life. I've learned the social environment is as important as logic aspects of the developing approach then I appreciate very much to get in touch with positive and eager colleagues that involve me in new and exciting challenges. This is why I still want to get involved in new opportunities to improve my skillness.

Updated on December 10, 2022

Comments

  • jazzbpn
    jazzbpn over 1 year

    This issue type 'SliverAppBar' is not a subtype of type 'PreferredSizeWidget' FLUTTER issue. came while trying to create a floating toolbar using SilverAppBar in FLUTTER.

    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),
            ),
          ),
        );
      }
    }