Left: Opacity on parent, Right: on children Keep in mind that if you apply opacity to individual children instead of fading the parent, you’ll also want to watch for visual changes due to compositing differences. We also created dedicated helper widgets, like a FadeColorTransition widget for fading blocks of color. In Wonderous, we used this approach to optimize fading images and text in a number of performance critical areas. work(url, opacity: AlwayStoppedAnimation(opacity)) images have an opacity parameter that accepts an Animation: Text('Hi!', style: TextStyle(color: m圜olor.withOpacity(opacity))) use withOpacity to apply opacity to colors:Ĭontainer(color: m圜olor.withOpacity(opacity)) ĬoloredBox(color: m圜olor.withOpacity(opacity)) Some examples include Container, ColoredBox, Text and Image. Some common Flutter widgets already contain an opacity or color parameter which is usually cheaper than using an opacity widget. This creates an extra opacity layer for Flutter to render, which can be expensive. #1: Avoid extra opacity layersĪ common cause of performance drains is using an AnimatedOpacity or Opacity widget where none is required. We learned a lot about rendering optimization, and wanted to share our top 5 tips to help you make your Flutter app run better. While building the Wonderous app, we wanted to create an experience rich in visuals and animation, but that maintained smooth performance and didn’t drain users’ batteries.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |