Last active
May 21, 2018 17:16
-
-
Save RafaelBarbosatec/c43993970526f657acf702c772fec09c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'Notice.dart'; | |
import 'NewsApi.dart'; | |
class NoticeList extends StatefulWidget{ | |
final state = new _NoticeListPageState(); | |
@override | |
_NoticeListPageState createState() => state; | |
} | |
class _NoticeListPageState extends State<NoticeList>{ | |
List _news = new List(); | |
var repository = new NewsApi(); | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: new AppBar(), | |
body: new Container( | |
child: _getListViewWidget(), | |
), | |
); | |
} | |
@override | |
void initState() { | |
loadNotices(); | |
} | |
Widget _getListViewWidget(){ | |
var list = new ListView.builder( | |
itemCount: _news.length, | |
padding: new EdgeInsets.only(top: 5.0), | |
itemBuilder: (context, index){ | |
return _news[index]; | |
} | |
); | |
return list; | |
} | |
loadNotices() async{ | |
List result = await repository.loadNews(); | |
setState(() { | |
result.forEach((item) { | |
var notice = new Notice( | |
item['url_img'], | |
item['tittle'], | |
item['date'], | |
item['description'] | |
); | |
_news.add(notice); | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment