Skip to content

Instantly share code, notes, and snippets.

@jesusrp98
Created January 9, 2019 19:47
Show Gist options
  • Save jesusrp98/e42fff1c30e6c01079ffe6a4dcb09991 to your computer and use it in GitHub Desktop.
Save jesusrp98/e42fff1c30e6c01079ffe6a4dcb09991 to your computer and use it in GitHub Desktop.
Example of Slivers & Swipers on the rocket's page
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(slivers: <Widget>[
SliverAppBar(
expandedHeight: MediaQuery.of(context).size.height * 0.3,
floating: false,
pinned: true,
actions: <Widget>[
// ...
],
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Text(_rocket.name),
background: Swiper(
itemCount: _rocket.getPhotosCount,
itemBuilder: (_, index) {
final CacheImage photo = CacheImage(_rocket.getPhoto(index));
return index == 0 ? Hero(tag: _rocket.id, child: photo) : photo;
},
autoplay: true,
autoplayDelay: 6000,
duration: 750,
onTap: (index) async => await FlutterWebBrowser.openWebPage(
url: _rocket.getPhoto(index),
androidToolbarColor: primaryColor,
),
),
),
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(children: <Widget>[
// ...
]),
),
),
]),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment