Skip to main content


Showing posts from December, 2018

A month of Flutter: real faker data

Originally published on Yesterday I left the code base with failing tests because the fixture data stored in a JSON file can't be read in Flutter tests. Today I'm going to complete the move to streamed mock data by switching from static fixtures to dynamic factories in a Dart file. The Unsplash image IDs will still be hard coded but the rest of the values will be dynamically generated. The core of the work will be performed in mockPostData. This will create a Map with a random UUID from the uuid package, a random image ID from the pre-selected list, a DateTime, and random text and username with the faker package. I have added a day between each DateTime value, so if I generate three posts, they will be from today, yesterday, and two days ago, respectively. Map<String,dynamic>

A month of Flutter: Stream transforms and failing tests

Originally published on Now that I've got a Post model with mock data and a StreamBuilder for rendering, it all needs to be wired together. The main changes I'm making are in _MyHomePageState where I'm replacing the stream of ints with a call to the new _loadPosts method. Stream<List<Post>>_loadPosts(BuildContextcontext){returnDefaultAssetBundle.of

A month of Flutter: rendering a ListView with StreamBuilder

Originally published on The data for Birb will be stored in Firebase Cloud Firestore. When looking at patterns to handle getting and rendering data, I decided to go with the StreamBuilder example from the cloud_firestore package documentation. I don't know how well pagination will work with this approach so that will be an experiment for another day. The first change I'm making is turning the static List<int> into a Stream, and moving it further up the widget tree. I want the PostsList widget to only care about rendering items from a Stream, not how to create the Streamitself. This has the bonus of making it easier to mock data in the tests. finalStream<List<int>>_posts=Stream<