Skip to content

Instantly share code, notes, and snippets.

@rrifafauzikomara
Created December 14, 2019 16:24
Show Gist options
  • Save rrifafauzikomara/e205ab7a064fcb89d679dae276d6a044 to your computer and use it in GitHub Desktop.
Save rrifafauzikomara/e205ab7a064fcb89d679dae276d6a044 to your computer and use it in GitHub Desktop.
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modularization/common/color_helper.dart';
class CardListMovies extends StatelessWidget {
final String image;
final String vote;
final String title;
final String releaseDate;
final List<Widget> genre;
final String overview;
const CardListMovies({Key key, this.image, this.vote, this.title, this.releaseDate, this.genre, this.overview}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(5),
child: Card(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// image
Container(
width: 130,
height: 200,
child: CachedNetworkImage(
imageUrl: image,
errorWidget: (context, url, error) => Icon(Icons.error),
),
),
// content
Container(
width: 260,
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// header
Container(
child: Row(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
// circle vote average
Container(
width: 40,
height: 40,
child: Stack(
children: <Widget>[
Center(
child: Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: Colors.blueGrey,
borderRadius: BorderRadius.circular(
20)),
),
),
Center(
child: Container(
width: 30,
height: 30,
child: CircularProgressIndicator(
strokeWidth: 3.0,
valueColor: AlwaysStoppedAnimation<Color>(
VoteColorHelper.getColor(
double.parse(vote))),
backgroundColor: Colors.grey,
value: double.parse(vote) / 10.0,
)),
),
Center(
child: Container(
width: 30,
height: 30,
child: Center(
child: Text(
(double.parse(vote) * 10.0)
.floor()
.toString() +
'%',
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 11,
color: Colors.white),
),
)),
)
],
),
),
SizedBox(
width: 10,
),
// title and release date
Flexible(
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
title,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 20),
),
Text(
releaseDate,
style: TextStyle(
color: Colors.grey[800],
fontSize: 14),
)
],
),
)
],
),
),
SizedBox(
height: 10,
),
// genre
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children:
genre,
),
),
SizedBox(
height: 10,
),
// description
Container(
width: 360,
child: Text(
overview,
softWrap: true,
maxLines: 6,
overflow: TextOverflow.ellipsis,
),
),
],
),
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment