Skip to content

Instantly share code, notes, and snippets.

@drexel-ue
Created April 17, 2018 13:57
Show Gist options
  • Save drexel-ue/837012120f48bb476cec5496ddbd6e3f to your computer and use it in GitHub Desktop.
Save drexel-ue/837012120f48bb476cec5496ddbd6e3f to your computer and use it in GitHub Desktop.
trying to use a listview with cards. for some reason i am not being allowed to enter my created variables
import 'package:flutter/material.dart';
class ListCard extends StatelessWidget {
final String backgroundImagePath;
final String title;
final String subtitle;
final int numberOfTrophies;
final IconData icon;
final Image iconAsset;
ListCard([
this.subtitle,
this.title,
this.backgroundImagePath,
this.icon,
this.iconAsset,
this.numberOfTrophies
]);
@override
Widget build(BuildContext context) {
return new Padding(
padding: const EdgeInsets.only(
left: 10.0,
right: 10.0,
bottom: 10.0
),
child: new Card(
elevation: 10.0,
child: new Column(
children: <Widget>[
new Image.asset(
backgroundImagePath,
width: double.infinity,
height: 150.0,
fit: BoxFit.cover,
),
new Container(
color: Colors.white,
child: new Row(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(15.0),
child: new Container(
padding: const EdgeInsets.all(10.0),
decoration: new BoxDecoration(
color: Colors.green,
borderRadius: new BorderRadius.all(
const Radius.circular(15.0)
)
),
child: new Image(
image: new AssetImage(backgroundImagePath)
)
),
),
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(title,
style: new TextStyle(fontSize: 25.0),
),
new Text(subtitle,
style: new TextStyle(fontSize: 17.0),
)
],
),
),
new Container(
width: 2.0,
height: 70.0,
decoration: new BoxDecoration(
gradient: new LinearGradient(
colors: [
Colors.green,
Colors.white
],
begin: Alignment.topRight,
end: Alignment.bottomRight
)
),
),
new Padding(
padding: const EdgeInsets.only(
left: 15.0,
right: 15.0
),
child: new Column(
children: <Widget>[
new Image.asset(
'assets/trophy_icon.png',
height: 30.0
),
new Text('$numberOfTrophies')
],
),
)
],
),
),
],
),
),
);
}
}
import 'package:flutter/material.dart';
import 'ui_elements/card.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: '1 Way',
theme: new ThemeData(
primarySwatch: Colors.green,
),
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget{
@override
State createState() => new MyHomePageState();
}
class MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin{
TabController tabController;
@override
void initState() {
super.initState();
tabController = new TabController(length: 4, vsync: this);
}
@override
Widget build(BuildContext context) {
return new Container(
child: new Scaffold(
backgroundColor: Colors.transparent,
appBar: new AppBar(
title: new Image.asset('assets/logo_white_text.png'),
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.menu, color: Colors.white),
onPressed: (){
//TODO:
}
),
bottom: new TabBar(
controller: tabController,
tabs: <Widget>[
new Tab(
child: new Image.asset('assets/freerun_page_title.png'),
),
new Tab(
child: new Image.asset('assets/compete_page_title.png'),
),
new Tab(
child: new Image.asset('assets/raffle_page_title.png'),
),
new Tab(
child: new Image.asset('assets/shop_page_title.png'),
)
],
),
),
body: new ListView(
children: <Widget>[
new ListCard(title), <<<<<<<<<< in android studio i get no option for auto complete
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment