Skip to content

Instantly share code, notes, and snippets.

@alfianyusufabdullah
Created June 14, 2019 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfianyusufabdullah/d1d4c7b01a93b6f8c92e70e075e04586 to your computer and use it in GitHub Desktop.
Save alfianyusufabdullah/d1d4c7b01a93b6f8c92e70e075e04586 to your computer and use it in GitHub Desktop.
class MealsDetail extends StatefulWidget {
final String id;
final String category;
final String mealThumbs;
const MealsDetail({Key key, this.id, this.mealThumbs, this.category})
: super(key: key);
@override
_MealsDetailState createState() => _MealsDetailState();
}
class _MealsDetailState extends State<MealsDetail>
with TickerProviderStateMixin {
...
requestData() async {
...
}
updateFavorite() {
...
}
@override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
),
);
return Scaffold(
body: WillPopScope(
onWillPop: () async {
close();
},
child: NestedScrollView(
controller: _scrollController,
headerSliverBuilder: (BuildContext context, bool inner) {
return <Widget>[
SliverAppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: close,
),
backgroundColor: _isTransparent
? Colors.transparent
: Color.fromARGB(220, 255, 255, 255),
expandedHeight: 270,
elevation: _elevation,
title: Text(_appBarTittle),
floating: false,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
background: Hero(
tag: "${widget.mealThumbs}-${widget.category}",
child: CachedNetworkImage(
imageUrl: widget.mealThumbs,
width: double.infinity,
fit: BoxFit.cover,
),
),
),
)
];
},
body: detail(),
),
),
);
}
Widget detail() {
if (_meals != null) {
return Stack(
children: <Widget>[
ListView(
padding: EdgeInsets.all(20),
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 10.0),
child: Text(
_meals.name,
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
),
),
Padding(
padding: EdgeInsets.only(top: 10),
child: TagsMeal(tags: _meals.tags),
),
Padding(
padding: EdgeInsets.only(top: 20.0),
child: Text("Ingredient",
style: TextStyle(
color: Colors.black,
fontSize: 17,
fontWeight: FontWeight.bold)),
),
Padding(
padding: EdgeInsets.only(top: 10.0),
child: CustomList(
data: _meals.ingredient,
),
),
Padding(
padding: EdgeInsets.only(top: 16.0),
child: Text("Steps",
style: TextStyle(
color: Colors.black,
fontSize: 17,
fontWeight: FontWeight.bold)),
),
Padding(
padding: EdgeInsets.only(top: 10.0),
child: CustomList(
data: _meals.steps,
),
)
],
),
Positioned(
bottom: 16,
right: 16,
child: ScaleTransition(
scale: _floatingAnimation,
alignment: FractionalOffset.center,
child: FloatingActionButton(
backgroundColor: Colors.pinkAccent,
onPressed: updateFavorite,
child: Icon(
_isFavorite ? Icons.favorite : Icons.favorite_border,
color: Colors.white,
),
),
),
)
],
);
} else {
return Center(child: CircularProgressIndicator());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment