All you need to know about Flutter 2.2

pubudu jayasanka
3 min readJun 11, 2021

Google introduced the new flutter 2.2 in their Google I/O event last month. They have introduced many more features to flutter with this release, including SDK for google payment and google ads. Not only that, they have released a new version of dart language, which is dart 2.13 that supports null safety. Let us talk about those brand new features today.

Before we start, If you don’t know who I am, you are welcomed to my personal blog DevPubba.com.

Dart 2.13 released

Dart 2.13 expands support for native interoperability, with support for arrays and packed structs in FFI. It also includes support for type aliases, null safety, increasing readability and providing a gentle pathway for certain refactoring scenarios.

Null safety

What is exactly null safety means. Let's understand it first.

As you can see, the following variable can never be null with the new dart null-safe. Because of that, if you assign null values to those variables, You’ll probably see warnings from the Dart analyzer

var i = 42; 
String name = getFileName();
final b = Foo();
// you will see warning for below code linevar i = null;

but, what if we need to allow null values for special cases. then you can let the dart analyzer know that you are allowing null values to that variable using syntax ?.

void main() {
int? a;
a = null;
print('a is $a.');
}

So, as you can see, unless you explicitly tell Dart that a variable can be null, it’s considered non-nullable.

Type aliases

Type aliases is a new feature in the 2.13 language. Using a type alias, you can create a new name for any existing type, which can then be used anywhere the original type could be used. You aren’t really defining a new type, just introducing a short-hand alias. The alias even passes type equality tests:

typedef Integer = int;
void main() {
print(int == Integer); // true
}

So what can you use type aliases for? One common use is to give a shorter or more descriptive name to a type, making your code more readable and maintainable.

DevTools suite

Let's see what you can do with the new flutter dev tool suite.

  • Inspect the UI layout and state of a Flutter app.
  • Diagnose UI jank performance issues in a Flutter app.
  • CPU profiling for a Flutter or Dart app.
  • Network profiling for a Flutter app.
  • Source-level debugging of a Flutter or Dart app.
  • Debug memory issues in a Flutter or Dart command-line app.
  • View general log and diagnostics information about a running Flutter or Dart command-line app.
  • Analyze code and app size.

I’ll be writing a separate article regarding flutter dev tools soon.

Please visit my blog for more reading on this topic …

https://devpubba.com/2021/06/11/flutter-2-2-all-new-features-you-need-to-know/

--

--