Declarative Status Bar Overlay Color in Flutter
Ever struggled with imperative SystemChrome API? See this short guide to make this process neat.
Ever struggled with imperative SystemChrome API? See this short guide to make this process neat.
Linkedin
Michael Lazebny on LinkedIn: #dart #flutter #declarative #appbar
Declarative Status Bar Overlay Color in Flutter
Have you ever struggled with switching between colors of the status/navigation bar on Android? There is an imperative solution to use SystemChrome.setSystemOverlayUiStyle, but there is an even better declarative…
Have you ever struggled with switching between colors of the status/navigation bar on Android? There is an imperative solution to use SystemChrome.setSystemOverlayUiStyle, but there is an even better declarative…
👍4
How to efficiently transform data using Codecs in Dart. Read in today's post :)
https://www.linkedin.com/feed/update/urn:li:activity:7130419429242224642/
https://www.linkedin.com/feed/update/urn:li:activity:7130419429242224642/
Linkedin
Michael Lazebny on LinkedIn: #dart #flutter #converter #json #utf8 #serialization
How to effectively serialize data in Dart & Flutter?
There is a very sophisticated way:
Dart has a built-in package called "dart:convert" that includes…
There is a very sophisticated way:
Dart has a built-in package called "dart:convert" that includes…
🔥6
When to use InheritedModel in Flutter?
Inherited widgets are a powerful, natural way to propagate information down the tree in Flutter.
The crucial thing is that they are O(1). It means, that the time needed to obtain an inherited widget from the tree is equivalent to constant.
When InheritedWidget changes (i.e., some data is updated), dependent elements are notified via didChangeDependencies and eventually rebuilt.
However, when clients (modules that depend on a widget) are interested only in a certain part of its data things become a bit complicated as the inherited widget doesn’t support it.
In such a case, the Inherited Model comes to our help. Basically, they extend the functionality of InheritedWidget by adding an aspect field.
Clients declare the aspect they’re interested in and are notified only if the data they’re interested in changes!
I’ve enclosed an example of an inherited model used for settings. Basically, when the client is interested in the locale -> it will be notified if the locale changes.
There is also a widget called MediaQuery that’s probably used by every #Flutter application. It also implements InheritedModel with its brightnessOf, sizeOf, and others.
LinkedIn
Inherited widgets are a powerful, natural way to propagate information down the tree in Flutter.
The crucial thing is that they are O(1). It means, that the time needed to obtain an inherited widget from the tree is equivalent to constant.
When InheritedWidget changes (i.e., some data is updated), dependent elements are notified via didChangeDependencies and eventually rebuilt.
However, when clients (modules that depend on a widget) are interested only in a certain part of its data things become a bit complicated as the inherited widget doesn’t support it.
In such a case, the Inherited Model comes to our help. Basically, they extend the functionality of InheritedWidget by adding an aspect field.
Clients declare the aspect they’re interested in and are notified only if the data they’re interested in changes!
I’ve enclosed an example of an inherited model used for settings. Basically, when the client is interested in the locale -> it will be notified if the locale changes.
There is also a widget called MediaQuery that’s probably used by every #Flutter application. It also implements InheritedModel with its brightnessOf, sizeOf, and others.
Linkedin
When to use InheritedModel in Flutter? | Michael Lazebny
When to use InheritedModel in Flutter?
Inherited widgets are a powerful, natural way to propagate information down the tree in Flutter.
The crucial thing is that they are O(1). It means, that the time needed to obtain an inherited widget from the tree is…
Inherited widgets are a powerful, natural way to propagate information down the tree in Flutter.
The crucial thing is that they are O(1). It means, that the time needed to obtain an inherited widget from the tree is…
👍11
How does #Flutter draw a frame?
The process can be initiated by several sources - setState, render object, system, or engine.
When you call setState, it marks the element as dirty and asks the engine (C++) for a frame via FFI. Later, when the engine is ready, it calls the WidgetsBinding.drawFrame callback.
The drawFrame iterates through the element tree and rebuilds dirty elements. If dirty elements change their size, color, or orientation (generally something that render objects are interested in) - render objects are marked as dirty.
Then the framework performs layout and painting.
Finally, the scene (or frame) is built and sent to the painting engine.
The process can be initiated by several sources - setState, render object, system, or engine.
When you call setState, it marks the element as dirty and asks the engine (C++) for a frame via FFI. Later, when the engine is ready, it calls the WidgetsBinding.drawFrame callback.
The drawFrame iterates through the element tree and rebuilds dirty elements. If dirty elements change their size, color, or orientation (generally something that render objects are interested in) - render objects are marked as dirty.
Then the framework performs layout and painting.
Finally, the scene (or frame) is built and sent to the painting engine.
🔥3👍2
Enhancing Image Rendering Efficiency
Handling large images often leads to excessive consumption of device memory. To tackle this issue, DevTools offers valuable insights into identifying images that are too large.
To optimize, consider setting 'cacheWidth' or 'cacheHeight' properties on your images. This approach decodes and stores images in memory at a designated size.
There is also a ResizeImage class in the SDK that can be used to resize the image.
See how the GSkinner team utilized AppImage in the Wonderous project, offering a real-world example of these techniques in action - https://buff.ly/46sE71y
#FlutterDev #Flutter #Performance
Handling large images often leads to excessive consumption of device memory. To tackle this issue, DevTools offers valuable insights into identifying images that are too large.
To optimize, consider setting 'cacheWidth' or 'cacheHeight' properties on your images. This approach decodes and stores images in memory at a designated size.
There is also a ResizeImage class in the SDK that can be used to resize the image.
See how the GSkinner team utilized AppImage in the Wonderous project, offering a real-world example of these techniques in action - https://buff.ly/46sE71y
#FlutterDev #Flutter #Performance
👍9
Media is too big
VIEW IN TELEGRAM
Use extent to optimize scrolling
If all elements have the same length along their main axis, it is recommended to set the
#Flutter #Performance
If all elements have the same length along their main axis, it is recommended to set the
extent
or utilize prototypeItem
. This will prevent the scrolling engine from laying out these widgets.#Flutter #Performance
👍8🔥4
formsf.png
648 KB
Implemented extremely simple forms for #Flutter that support asynchronous validators 👀
👍7🔥4
A while ago compute function from flutter SDK has moved to dart.
Incredibly easy and efficient way to process something in a different thread.
https://youtu.be/PPwJ75vqP_s?si=bqjge122nwFCBkIw
Incredibly easy and efficient way to process something in a different thread.
https://youtu.be/PPwJ75vqP_s?si=bqjge122nwFCBkIw
YouTube
Isolates (Technique of the Week)
If your Flutter app has jank due to a heavy computation, use Isolate.run() to move that computation to a new isolate.
Isolate class → https://goo.gle/3vvBKi4
Use isolates in your Flutter app → https://goo.gle/43DiXxL
Article about Isolate.run → https…
Isolate class → https://goo.gle/3vvBKi4
Use isolates in your Flutter app → https://goo.gle/43DiXxL
Article about Isolate.run → https…
🔥7👍6🎉2