Skip to content

Instantly share code, notes, and snippets.

@rrifafauzikomara
Created December 14, 2019 15:28
Show Gist options
  • Save rrifafauzikomara/3a109973bc9b150c7d26604811a0cd0a to your computer and use it in GitHub Desktop.
Save rrifafauzikomara/3a109973bc9b150c7d26604811a0cd0a to your computer and use it in GitHub Desktop.
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
class Poster extends StatelessWidget {
static const POSTER_RATIO = 0.7;
Poster(
this.posterUrl, {
this.height = 100.0,
});
final String posterUrl;
final double height;
@override
Widget build(BuildContext context) {
var width = POSTER_RATIO * height;
return Material(
borderRadius: BorderRadius.circular(4.0),
elevation: 2.0,
child: CachedNetworkImage(
imageUrl: posterUrl,
fit: BoxFit.cover,
width: width,
height: height,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment