Getting Ready for Get v5

Flutter’s most like package

Jody McAlister
Flutter Town
4 min readJun 26, 2023

--

random code across a computer screen
Photo by Florian Olivo on Unsplash

Hey there! I wanted to write this article in response to all the recent anti-Get articles I’ve been reading on Medium. Now, let me clarify upfront that this isn’t an announcement that v5 is being promoted to stable. Instead, I want to share a few tips for those of you who are currently using Get v4 and are interested in trying out the latest release candidate. V5 requires a minor update to Get.to(View()) and also adds animation capabilities among other new features I have yet to discover.

Before using Get, state, route and dependency management coding felt clunky and frankly not an enjoyable experience. I’ve successfully used Provider and BLoC, but have happily settled into using Get to cover all my needs. When I say happily, I really mean it.

Some of the recent anti-articles reference the fact that as of this article, version 4.6.5 has been the last version released for the last 13 months. They fail to mention that there are v5 release candidates they could be using now and that the delay has been acknowledged and explained by the developer (who has other duties besides this package) and that the amount of features, changes and updates to the documentation is a huge task in itself.

When I first started using Flutter (during its last alpha version), my main goal was to find a cross-platform solution for developing mobile apps on both Android and iOS. However, I struggled with finding a clear Model-View-Controller (MVC) option. Thankfully, that problem was solved for me when I discovered Get.

Clear Separation of Concerns

Controllers help to separate the business logic from the UI, leading to cleaner and more maintainable code. The UI only needs to know about the state it displays, not how to update it. This separation of concerns makes your code easier to test, debug, and understand.

Efficient State Management

Controllers in Get are reactive. When you change the state in a Controller, any widget that uses that state will automatically be updated. This reactive nature eliminates the need to manually call setState(), leading to more readable code and efficient state management.

Lifecycle Management

Get Controllers have lifecycle methods (onInit, onReady, and onClose) that you can override to perform setup and cleanup tasks. For instance, you can initiate API calls in onInit or onReady, and cancel any ongoing operations or close streams in onClose.

Dependency Management

Controllers can be used with Get’s dependency management system. You can define a Controller as a dependency using Get.put(), and then retrieve it anywhere in your app using Get.find(). This makes it easy to share data between different parts of your app.

Controllers in Get are a powerful tool that can help you write efficient, clean, and maintainable Flutter applications. By harnessing the power of Controllers, you can take your Flutter development to the next level.

Get boasts an easy and pleasant syntax. It aims to save hours of development time and provide the maximum performance your application can deliver. With Get, developers don’t need to worry about removing controllers from memory. Resources are removed from memory when they are not being used by default, which can help to prevent memory leaks and unnecessary resource usage.

Get allows for total decoupling of the View, presentation logic, business logic, dependency injection, and navigation. You do not need context to navigate between routes, so you are not dependent on the widget tree for this. This decoupling can lead to cleaner, more maintainable code.

Some of the new and changes to Get v5

When using Get v5, there are some changes that developers should be aware of. One of the most notable changes is the update to the navigation syntax. In Get 4.x.x, you could navigate to a new page using the `Get.to()` method and passing the destination widget directly:

Get.to(Home());

However, in Get 5.x.x, you need to pass a function that returns the destination widget to the `Get.to()` method:

Get.to(() => Home());

This change allows for more flexibility and control over the navigation process, such as delaying the creation of the destination widget until it’s actually needed. I’m actually using routes in Get rather than these calls anymore, but some apps I’m updating still call new views this way.

Another exciting feature in Get 5.0 is the addition of animation extensions. These extensions allow developers to create complex animation sequences with a simple and readable syntax. For example:


const FlutterLogo(size: 110)
.bounce(begin: -0.8, end: 0.4)
.fadeIn()
.spin(isSequential: true)
.wobble(isSequential: true, begin: 0, end: 8)
.flip(isSequential: true)
.fadeOut(isSequential: true),

Compare this to using the animate_do package which is also a favorite of mine.

If you are unfamiliar with Get, this article barely scratches the surface. Read some of the anti-Get articles yourself and make sure you have all your bases covered, but I love it and will be sticking with it. Check Get out at Pub.dev.

For those just getting started in Flutter, here’s a few things to help you start.

--

--