Reputation: 611
I cant seem to find the answer to this simple problem but I dont understand why my Stack is BELOW the appbar and not BEHIND it. Also, this is a custom appbar
What Im trying to achieve: The image should be BEHIND the appbar and not below it, meaning the appbar will overlap the image or is in front of the image
my code for this is this:
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
elevation: 1,
backgroundColor: Colors.transparent,
),
body: ListView(
children: <Widget>[
Stack(
children: <Widget>[
Hero(
tag: widget.discount.name,
child: ShadowClip(
clipper: CircularClipper(),
shadow: Shadow(blurRadius: 0.0),
child: FadeInImage.assetNetwork(
placeholder: 'assets/images/placeholder.png',
height: 200.0,
width: double.infinity,
fit: BoxFit.cover,
image: widget.discount.imageUrl.Url,
),
),
),
// Positioned(
// top: 0, left: 0, right: 0, bottom: 0,
// child: DetailPageAppbar(height:60),
// ),
],
),
Upvotes: 1
Views: 1142
Reputation: 489
Please try below code and check output
SafeArea(
child: Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
elevation: 1,
leading: Icon(Icons.arrow_back_ios),
backgroundColor: Colors.transparent,
),
body: Stack(
children: <Widget>[
Column(
children: <Widget>[
Flexible(
flex: 3,
child: Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
"https://picsum.photos/250?image=9")))),
),
Flexible(
flex: 6,
child: ListView.builder(
itemCount: 50,
itemBuilder: (BuildContext context, int pos) {
return ListTile(
title: Text("121"),
);
},
),
)
],
)
],
),
));
Upvotes: 3
Reputation: 678
Do this:
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
extendBodyBehindAppBar: true,
appBar: Header(),
//...
} //end method build
PreferredSize Header() {
return PreferredSize(
preferredSize: Size.fromHeight(56.0), //default appbar height (material design principles)
child: Container(
color: Colors.Transparent,
child: Center(
child: Text("APPBAR TEXT"),
),
),
);
} //end method Header
Upvotes: 1