TransWikia.com

Flutter: SilverAppBar Background Image with Text

Stack Overflow Asked by gsk on December 2, 2020

I am trying to make an app bar looks like this:

enter image description here

I hope to collapse the big image using SilverAppBar, but I am having hard time to insert AssetImage (or Image.asset'). I almost exactly followed the code from the [official Flutter website][2], and unfortunately, both AssetImageandImage.asset` cannot be used as shown below:

enter image description here

Is there any way to do this?

2 Answers

maybe you can use background like this:

SliverAppBar(
...
...
   background: Image(
      image: NetworkImage(recipeDetails.coverPhoto),
      fit: BoxFit.cover,
      ),
   ),

Answered by xion on December 2, 2020

Wrap Image.asset with Container widget

          Stack(
                  fit: StackFit.expand,
                  children: <Widget>[
                    Container(
                      child: Image.asset('name'),
                    )
                    ],
                ),

Answered by Titas Černiauskas on December 2, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP