Skip to content

Instantly share code, notes, and snippets.

@jwiese-ms
Last active January 24, 2020 15:06
Show Gist options
  • Save jwiese-ms/96bccf0e08b7a413c098f810e9d9bf5c to your computer and use it in GitHub Desktop.
Save jwiese-ms/96bccf0e08b7a413c098f810e9d9bf5c to your computer and use it in GitHub Desktop.
SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// this needs to work with the control, should be able to get the size of the display we are on, not the whole device.
crossAxisCount: ((MediaQuery.of(context).size.width > 540 ? 540 : MediaQuery.of(context).size.width) / 200).round(),
),
delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
return CastTile(castMember: currentCast[index]);
},
childCount: currentCast == null ? 0 : currentCast.length,
),
),
// in CastTile() here is how I handle the lazy loading of the cast images
Container(
height: 100,
width: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
image: DecorationImage(
image: usePlaceholder ? AssetImage('assets/castplaceholder.png') : NetworkImage('https://image.tmdb.org/t/p/w500/' + castMember['profile_path']),
fit: BoxFit.cover,
),
boxShadow: [
BoxShadow(
color: Colors.black,
blurRadius: 20.0,
offset: Offset(0.0, 10.0),
)
],
),
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment