News and views on the world of interactive media from the gskinner team
Category / Architecture
When it comes to implementing a url-based Router (aka Nav2) there are really 2 high-level components to the API:
A controller to read/write to the current url
A parsing/matching system to convert a url into a stack of views, or pages.
The interesting thing here, is that the controller portion, is a fairly stable, boring API. Reading or writing the url location, or accessing queryParams is all pretty straight-forward. Really all you are doing here is setting a string value, and parsing query params using the URI class.
Recently we took a deep dive into the new skeleton template included in the Flutter SDK. As noted in the article, one of the big missing pieces in the template is a scalable state management solution with dependency injection and data-binding.
Given that, we thought it would be informative to convert it to use a couple of popular state management libraries, specifically riverpod and GetItMixin.
If you’re not familiar with GetIt, it is a robust implementation of the classic service locator pattern, which allows you to register objects by their type and then look them up from anywhere in the app. Recently it gained a sibling package named GetItMixin which provides reactive widget binding hooks. Combined these two packages make up one of the simplest and cleanest methods of managing state within a Flutter application. Let’s take a look!