Created
January 31, 2019 16:17
-
-
Save umuieme/327eb8c2e5f48d9e73b552a20882d11a 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
class _EventContentState extends State<EventContent> with AutomaticKeepAliveClientMixin<> { | |
final String url = 'https://furnishmenow.co.za/wp-json/wp/v2/posts'; // Testing url | |
List data; | |
Future<String> getEventContentData() async{ | |
var res = await http.get(Uri.encodeFull(url), headers: { "Accept": "applications/json"}); | |
setState(() { | |
var resBody = json.decode(res.body); | |
data = resBody; | |
}); | |
return "Success"; | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
child: ListView.builder( | |
itemCount: data == null ? 0 : data.length, | |
itemBuilder: (BuildContext context, int index){ | |
return Container( | |
child: Center( | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.stretch, | |
children: <Widget>[ | |
Card( | |
child: Container( | |
color: Colors.grey, | |
padding: EdgeInsets.all(15.0), | |
child: Column( | |
children: <Widget>[ | |
Image.network('https://furnishmenow.co.za/.../2018/05/website_front.jpg', height: 150.0,), // Dummy image | |
Container( | |
padding: EdgeInsets.only(top:10.0, bottom: 10.0), | |
child: Text(data[index]["title"]["rendered"], style: TextStyle(color: Colors.white, fontSize: 20.0),), | |
), | |
Text(data[index]["content"]["rendered"], style: TextStyle(color: Colors.white),), | |
], | |
) | |
), | |
), | |
], | |
), | |
) | |
); | |
}, | |
), | |
); | |
} | |
@override | |
void initState() { | |
super.initState(); | |
this.getEventContentData(); | |
} | |
@override | |
// TODO: implement wantKeepAlive | |
bool get wantKeepAlive => true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment