One thing that I keep forgetting how to do in Flutter is determine if a Widget is the topmost visible widget or has been obscured by the Navigator pushing another widget on top of it. It’s really simple so I’m recording it here so I don’t have to search for it again.
I recently started using the excellent google_sign_in package to handle Google authentication for access to services on the user’s behalf. Using this a user can allow access to their account in a service like Google Calendar. The documentation is very good but there was one point that tripped me up. In hopes it will save you some time here’s what I discovered. The login flow goes something like this: My initial version didn’t use the signInSilently method and I didn’t at first understand what the use case was. What I missed is that the first time the user signs in [Read on…]
Flutter’s navigation and routing definitions are great tools for handling moving from one page of an application to another and back. In particular named routes make it simple to decouple implementation from intent. The standard navigation behaviour using named routes is to create a MaterialPageRoute using a widget. If you want to use a popup route or some other modal artifact that doesn’t work. Turns out it’s simple to override this behaviour and this post explains how. Basic named routes Using navigation with named routes is pretty simple. First declare the route in the routes table as part of the [Read on…]
Markdown content has become pretty ubiquitous and along with that comes the requirement to parse it into its constituent parts. Sometimes it’s useful to know what links it contains, or to count the headings, etc. Writing parsers is super fun in comp sci class, and not too bad with something like Antlr, but when someone else has already done the work, so much the better. Dart has a very capable Markdown parser that is only missing a little bit of documentation to make it fit this more general requirement. This post fills in that bit of documentation. The Basics Markdown [Read on…]
I’ve just figured out Flutter error handling for method channels communicating with native code and wanted to capture the technique. This is something that I missed despite a fair amount of reading on plugin integration, so others might have missed it as well. There’s a very good post, Flutter Platform Channels, where I got much of this information, definitely worth a read. There are some details that it doesn’t cover, particularly about testing, and it’s not just focused on error handling, so I thought I’d boost the signal on that. Error structure An error communicated across a method channel is [Read on…]
I was recently reviewing the options for app internationalization in Flutter and there was quite a lot of discussion and content written about it. In this post I’ll describe what I think the right choice is and why, as well as provide a few missing how to guides. The short version of the post is that I think you should use the built-in Flutter tools and avoid some of the suggested alternatives. Alternatives Flutter tools Flutter has a set of tools for handling Internationalization, the intl and intl_translation packages. I think the Flutter team has done a very good job [Read on…]
Creating plugins for Flutter is well documented and pretty easy. Unit testing the resulting native code in iOS wasn’t quite as straightforward so I thought I’d capture what I did while I still remember the steps. This post shows how to create a new plugin for Flutter with a Swift implementation for iOS, and then add Swift XCTest unit tests for that implementation. Creating a new plugin To create my first plugin I followed the Flutter docs, in particular the section on Developing plugin packages. I used the version of the create command that specified the native languages, like so: [Read on…]