Announcing Flutter 1.20
By Philomathes in Flutter
So Flutter 1.20 is now out and this is what Flutter has for all of us in store for this time
- Reducing shader compilation jank on mobile
- Developing for iOS 14 beta
- New instructions for installing Flutter on Linux using snapd.
- Updated the Desktop support page to reflect that Linux desktop apps (as well as macOS) are available as alpha.
- Null safety has been added to dart.dev
1) Reduce shader compilation jank on mobile
If the animations on your mobile app appear to be janky, but only on the first run, you can warm up the shader captured in the Skia Shader Language (SkSL) for a significant improvement.
If an app has janky animations during the first run, and later becomes smooth for the same animation, then it’s very likely due to shader compilation jank.
More technically, a shader is a piece of code that runs on a GPU (graphics processing unit). When a shader is first used, it needs to be compiled on the device. The compilation could cost up to a few hundred milliseconds whereas a smooth frame needs to be drawn within 16 milliseconds for a 60 fps (frame-per-second) display. Therefore, a compilation could cause tens of frames to be missed, and drop the fps from 60 to 6. This is compilation jank. After the compilation is complete, the animation should be smooth.
How to use SkSL warmup
Use the following instructions to collect and package the SkSL shaders:
- Run the app with –cache-sksl turned on to capture shaders in SkSL:
flutter run --profile --cache-sksl
- Play with the app to trigger as many animations as needed; particularly those with compilation jank.
- Press M at the command line of flutter run to write the captured SkSL shaders into a file named something like flutter_01.sksl.json.
- Build the app with SkSL warm-up using the following, as appropriate:
flutter build apk --bundle-sksl-path flutter_01.sksl.json
flutter build ios --bundle-sksl-path flutter_01.sksl.json
- Test the newly built app.
flutter drive --profile --cache-sksl --write-sksl-on-exit flutter_01.sksl.json -t test_driver/app.dart
With such integration tests, you can easily and reliably get the new SkSLs when the app code changes, or when Flutter upgrades. Such tests can also be used to verify the performance change before and after the SkSL warm-up. Even better, you can put those tests into a CI (continuous integration) system so the SkSLs are generated and tested automatically over the lifetime of an app.
2) Developing for iOS 14 beta
- Developing for iOS 14 beta outlines some issues you might run into if developing for devices running iOS 14 beta.
- The iOS 14 release, the new version of Apple’s mobile operating system, is coming. As it’s not yet stable, we don’t fully support it yet.
- But we have some tips to get you up and running — assuming that you don’t mind being on the leading edge.
Using hot reload
When you run your app for the first time in debug mode, iOS 14 presents a popup dialog asking you to allow local network connections. If you choose Don’t Allow, hot reload won’t work, because it prevents the app from talking to Observatory.
Solution: Choose OK to allow local network connections.
Just to be clear: this only happens in debug mode. Your users won’t see this message in release mode. Only the debug version of your app needs to access the local network.
3) New instructions for installing Flutter on Linux using snapd
4) Updated the Desktop support page to reflect that Linux desktop apps (as well as macOS) are available as alpha.
For macOS desktop development, you need the following in addition to the Flutter SDK:
For Linux desktop development, you need the following in addition to the Flutter SDK:
The easiest way to install the Flutter SDK along with these dependencies is by using snapd.
Once you have snapd, you can install Flutter using the Snap Store, or at the command line:
sudo snap install flutter --classic
If snapd is unavailable on the Linux distro you’re using, you might use the following command:
sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev
Create a new project
You can use the following steps to create a new project with desktop support.
flutter channel dev flutter upgrade flutter config --enable-<platform>-desktop
Where <platform> is either
flutter config --enable-macos-desktop flutter config --enable-linux-desktop
To ensure that the desktop is installed, list the devices available. You should see something like the following (you’ll see either macOS or Linux, not both):
flutter devices 1 connected device:macOS desktop • macos • darwin-x64 • Mac OS X 10.15.5 19F101 Linux desktop • linux • linux-x64 • Linux
To launch your app from the command line, enter one of the following from the top of the package:
flutter run -d macos flutter run -d linux
Build a release app
To generate a release build run one of the following commands:
flutter build macos flutter build linux
5) Null safety has been added to dart.dev
For understanding null safety, you call follow this link – Understanding null safety