Skip to content

Instantly share code, notes, and snippets.

@smoj
Created January 27, 2020 20:22
Show Gist options
  • Save smoj/52e69039c7fa7e8708607eb2813e4aaf to your computer and use it in GitHub Desktop.
Save smoj/52e69039c7fa7e8708607eb2813e4aaf to your computer and use it in GitHub Desktop.
A demonstration of a fully custom UI Widget using Flutter's Material Widgets
FeedItem(
title: 'Himalayas',
timestamp: '23 Mins ago',
category: 'SOCIAL',
imageUrl: 'https://i.picsum.photos/id/866/400/400.jpg',
),
import 'package:flutter/material.dart';
class FeedItem extends StatelessWidget {
final String imageUrl;
final String title;
final String timestamp;
final String category;
FeedItem({this.imageUrl, this.title, this.timestamp, this.category});
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Container(
height: 400,
color: Colors.pink,
),
Positioned(
top: 0,
bottom: 0,
left: 0,
right: 0,
child: FittedBox(
fit: BoxFit.fill,
child: Image.network('$imageUrl')
),
),
Positioned(
top: 0,
left: 0,
bottom: 0,
right: 0,
child: Container(
color: Color.fromRGBO(0, 0, 0, 0.3),
height: 400,
),
),
Positioned(
top: 0,
left: 0,
bottom: 200,
right: 0,
child: Padding(
padding: EdgeInsets.fromLTRB(6, 20, 0, 0),
child: RotatedBox(
quarterTurns: 3,
child: Text(this.category, style: TextStyle(
color: Colors.white,
fontFamily: 'Montserrat',
fontSize: 15,
fontWeight: FontWeight.w700,
letterSpacing: 8
),),
),
),
),
Positioned(
bottom: 0,
top: 220,
left: 13,
child: Container(
width: 1,
decoration: BoxDecoration(
color: Color.fromRGBO(255, 255, 255, 0.5),
),
),
),
Positioned(
bottom: 40,
left: 40,
right: 20,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(this.title, style: TextStyle(
color: Colors.white,
fontFamily: 'Yrsa',
fontWeight: FontWeight.w600,
fontSize: 40
),),
Row(
children: <Widget>[
Icon(Icons.timer, color: Colors.white,),
SizedBox(width: 7,),
Text(this.timestamp, style: TextStyle(
color: Colors.white,
fontFamily: 'Montserrat',
fontWeight: FontWeight.normal,
fontSize: 20
),),
],
)
],
),
),
],
);
}
}
@dirisujesse
Copy link

Cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment