Do you ever get distracted at work? Yes, me too…
We get distracted. By someone, a live issue, a meeting, a colleague asking a quick question, a broken build pipeline, and so on. Reasons are plenty.
We forget “where we were”.
Every workday, I write an ordered list of tasks I will do at the start of the next workday.
Just before logging off, I set aside 5 minutes.
This is useful to do this every workday. Don’t skip it. Particularly, don’t skip it on Friday at 5.30pm. I know you want to get out of the building, but stay 5 more minutes, you will thank yourself for it on Monday morning.
Continue reading “Software developers: the 5 minutes habit that will boost your workday”
When it comes to mobile apps, automated tests play a very important role in app maintenance. So, how do you write tests in Flutter?
As you would expect from a modern framework, Flutter offers both unit and integration tests. But it also offers something else: widget tests.
Widget tests are in between unit and integration. Like a unit test, they run on a simpler test environment (whereas integration tests run on an emulator or device). But they can actually test the UI. You can write a widget test that taps on a button.
With the Android SDK, I write UI tests with Espresso. It works well but the tests take a long time to run. It’s not a problem with CI, as we can use some good sharding libraries. But while I develop, I often run a subset on my local machine, to verify my work, and I get frustrated.
Therefore, I find the concept of widget tests very welcome. It will reduce the number of integration tests on a production app, moving some of them to widget tests.
In this code tutorial, we will create an app with a list page and a details page. On the details page, we can select/unselect an item. Its selected status is shown on the list page via a different background colour.
Then, we will write unit and widget tests to verify the behaviour of the app.
Continue reading “Flutter widget tests: a practical example”
Flutter makes creating custom UI experiences easy. It really does. I mean it.
One example is complex gestures. How about starting a drag gesture to trigger something, and then moving the finger to control something else, and finally dropping it to confirm?
Continue reading “How to implement gestures across several widgets in Flutter”
A common pattern when showing a list on a website is allowing the users to filter it with a search term. So, how do you do this in AngularDart?
In this code tutorial, which uses AngularDart 5.0, we will create a simple web app with a list. Above the list, in a sibling component of the list, we will show an input field and a clear button. As the user types in the input, the list is filtered accordingly. If the user taps the clear button, all the items of the list are shown again and the input field is cleared.
The code is available on github.
Continue reading “How to filter a list in AngularDart”
A few weeks ago, I decided to publish my first Flutter app on the Apple app store. The app had been published on Android for almost a year, but I had actually never tested it on an iPhone. Did Flutter live up to its cross platform claims?
Here are a few things to consider & watch out for, especially if you come from an Android background.
Continue reading “Publishing my first iOS app with Flutter”
It’s quite common for a native Android app to use productFlavors to set up several apps from the same source code. So, how easy is this to implement in Flutter?
In this code tutorial, we will set up a project with 2 app flavors. Each app will display the app name (specific per flavor), the current date (shared functionality, which includes a string), a short description (specific per flavor), and two images (one specific per flavor, one shared).
Continue reading “Creating flavors of a Flutter app (Flutter & Android setup)”
You may be an Android or Java developer, you’ve heard about Flutter, and are curious. So, is Dart easy to pick up as a Java developer?
The official website claims that Dart is “familiar to many existing developers”, and I generally agree with this statement. There is now a codelab Intro to Dart for Java developers: I do recommend you at least skim through it to get an overview.
In addition to the codelab, below is a list of concepts you will probably need to know fairly quickly.
Continue reading “From Java to Dart”
setState … Once you code an app of medium complexity, it becomes very important to think about the performance impact of your Flutter widgets.
Thinking about app performance is about being a good app citizen. Not only the app will be smoother for the user, but also it will drain less battery. And we all know battery is still the single point of failure for smartphones!
The official Stateful Widget doc has some very helpful information on performance considerations. Here, I will focus on the first item: “Push the state to the leaves”.
In this code tutorial, we will set up a screen with a list of shopping items. Each item displays a title and a picture. Some items actually have several pictures available, so we will loop through them in the display, with the picture changing for that item every 2 seconds.
Continue reading “Improve your Flutter app performance: split your widgets”
I’ve spent the last 3 months being the sole developer for a fairly complex Flutter app for a client. It’s been very fun and Flutter is, generally, a pleasure to code with.
It’s also been a learning experience, so I’ve compiled a list of the 5 most important lessons (for me).
Split your stateful widgets
Often, we refactor classes when a file gets big, and that’s fine. But there is another reason to split a stateful widget in Flutter. Remember that the whole widget rebuilds when your code calls setState()? So split your widgets between their static and dynamic content, separate widgets if they contain 2 visual parts that obtain their data separately etc
Example: I had a stack of images, inside a list, and some of the images contained animations. With a simple logic, all the stack code fitted in under 100 LOC in one widget. However, scrolling was a bit jerky. I improved it by creating a widget for each image, and animating those as and when required, instead of rebuilding the whole stack.
Update 29/06/18: I’ve simplified and turned the example above into a code tutorial Improve your Flutter app performance: split your widgets
Continue reading “5 lessons learned while working on a complex Flutter application”
You may have heard that Dart is single threaded. Coming from a Java/Android background, it can be confusing. How do you handle async code? What concept replaces Android’s AsyncTask and Java’s threads? And how do you implement a callback?
The concept is called Futures. A Future completes with either a value or an error. You use a try/catch statement to catch the error. To create a Future, you use a Completer.
This all sounds very abstract, so let’s dive into an example.
In this code tutorial, we will set up a screen with 2 separate widgets. Both widgets use the same data repository as their data source. The data repository needs to make an API call to initialise its data. While it does so, the widgets show they are waiting for the data. When the data is ready, the widgets display it.
Continue reading “How to write async code in Flutter”