POC of coding Henri Potier exercise with Flutter Beta.
Live Coding focus on book list retrieval and list display, it should take ~15 min.
- Create a new Flutter project
- Remove extra comments
- Create
Bookclass withtitle - Add
_bookto_MyHomePageState - Remove method
_incrementCounter - Add
ListView.builder - Use
=> TextasitemBuilder - Then use
=> ListTile - Override
initState - Add
async,http,convert
import 'dart:async';
import 'package:http/http.dart' as http;
import 'dart:convert';
- Add method
fetchBooks
Future<List<Book>> fetchBooks() async {
final response = await http.get('http://henri-potier.xebia.fr/books');
final json = JSON.decode(response.body);
final books = List<Book>();
for (final jsonBook in json) {
books.add(Book(jsonBook['title']));
}
return books;
}
- Code method
initState
@override
void initState() {
super.initState();
fetchBooks().then((books) {
setState(() {
this._books = books;
});
});
}
- Live coding can stop here, or go further if more time
- Add
covertoBookand convert fromJSON - Add
Image.networktoListTile - Add
ColumnthenDividertoitemBuilder
That's it folks!


