Reputation: 2599
Right now I have an image on my Floating Action Bar (FAB) but it looks like it's on top of it. I would like it to fill the entire inside / shape of the button
floatingActionButton: FloatingActionButton.large(
heroTag: "add image",
backgroundColor: const Color(0xFF93C3B9),
child: (imageURL == ' ')
? const Icon(Icons.add_a_photo_outlined)
: Container(
//height: 75,
//width: 75,
child: Stack(fit: StackFit.expand, children: [
const Center(
child: CircularProgressIndicator(),
),
Center(
child: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: imageURL,
fit: BoxFit.fill,
),
),
),
]),
),
Upvotes: 1
Views: 1090
Reputation: 10172
Another option is to try clipBehavior: Clip.antiAliasWithSaveLayer
floatingActionButton: FloatingActionButton.large(
heroTag: "add image",
backgroundColor: const Color(0xFF93C3B9),
clipBehavior: Clip.antiAliasWithSaveLayer,
onPressed: () {},
child: Stack(
...
),
),
Upvotes: 0
Reputation: 11219
You may just set the backgroundColor of the FAB to transparent, backgroundColor: Colors.white.withAlpha(0)
and elevation: 0
:
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.white.withAlpha(0), // add this line.
elevation: 0, // also important, removes the shadow
heroTag: "floatingActionBtn",
child: Image.asset("assets/images/myImage.png"), onPressed: () => myFunction(myArg)),
Upvotes: 0
Reputation: 63604
Try to remove Center
widget. Constraints goes down on flutter.
floatingActionButton: FloatingActionButton.large(
heroTag: "add image",
backgroundColor: const Color(0xFF93C3B9),
onPressed: () {},
child: Stack(
fit: StackFit.expand,
children: [
const Center(
child: CircularProgressIndicator(),
),
ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: imageURL,
fit: BoxFit.cover,//prefer cover over fill
),
),
],
),
),
Upvotes: 1