Creating services to do the work in your Flutter app

Suragch
Flutter Community
Published in
11 min readJan 13, 2020

--

A guide to using the GetIt package

Get your employees to do the heavy work.

If you are reading this article again for a quick refresher, scroll down to the Summary section at the bottom.

In a previous article I talked about an easy way to architect a Flutter app using the stacked package package by FilledStacks. The main idea was to use the MVVM pattern to remove any logic from the UI layout by putting it in a view model. This makes for a much cleaner and more maintainable app.

The View is the the widget tree for a single page.

It would be a mistake, though, to have the view models do all the work. Their main job is just to get the data ready to display in a view. The heavy work should be passed off to services. This is a further separation of concerns, which is a win for maintainable apps.

In that last article I mentioned services, but I didn’t talk much about how to make them. In this article I’ll cover services in more depth and show you how to use them in your own Flutter app. This topic is independent of MVVM, and you can use the service pattern even if you are using a different architectural style.

What are services?

--

--