Comments (3)
Performance
In a very contrived benchmark (#148261) const
ness was giving us a speed-up in build times of 13-16% on a Moto G4. However, the benchmark was very artificial and we should test it with something that's closer to a real world app. I am going to create a version of the flutter_gallery that doesn't use any const
instantiations outside of the framework and see how a run of the transition benchmark compares to a const
ified flutter_gallery. I will run this on a mid-range Android phone with route snapshotting disabled.
Naginess
From playing around with this a bit with the flutter_gallery app, the biggest offenders here are prefer_const_constructors
and prefer_const_literals_to_create_immutables
. These constantly fire as you're iterating on your build method. And they are also often flip-flopping, what makes them even more annoying: You make a thing const because the lint told you so, then you iterate in a way that it cannot be const anymore and the analyzer yells at you again for that.
The prefer_const_constructors_in_immutables
is the least annoying lint in the group. In fact, it is hardly annoying at all because it is fairly stable and as your code evolves you don't have to go back and forth on this one. Even if we disable the other lints, this one may be good to keep because it keeps the door open for developers to decide on a case by case basis if they want to be more strict and enable the other const lints. If we stop enforcing prefer_const_constructors_in_immutables
they may no longer have the option to const-construct a widget because the widget may not offer a const constructor.
The prefer_const_declarations
lint is in a bit of a grey area. It does not feel particularly annoying. But it also doesn't feel super-useful on its own without prefer_const_literals_to_create_immutables
and prefer_const_constructors
. So, if we end up disabling those I am leaning towards disabling this one as well.
Summary
Do more performance testing with a benchmark that's closer aligned with the real world. If const
ness doesn't make a huge difference (threshold TBD) recommend removing prefer_const_constructors
, prefer_const_literals_to_create_immutables
, and prefer_const_declarations
from package:flutter_lints
, but likely keep prefer_const_constructors_in_immutables
. If const
ness makes a difference, we'll work with the language/analyzer team to figure out if we can make this less annoying (e.g. by introducing better quick fixes in the analyzer or by looking into introducing something like autoconst to the language).
from flutter.
FYI @mit-mit @jonahwilliams @johnpryan @srawlins
from flutter.
Related: dart-lang/sdk#53744
from flutter.
Related Issues (20)
- iOS app crashes in Simulator running on mac virtualized environment HOT 9
- Video Player progress downloading (download only part of the video provided in the network which is enough to play a few seconds from it). while playing these seconds I want to initialize the rest of the video HOT 1
- Video Player progress downloading (download only part of the video provided in the network which is enough to play a few seconds from it). while playing these seconds I want to initialize the rest of the video HOT 1
- %5Btool_crash%5D FileSystemException%3A Cannot open file%2C OS Error%3A The system cannot find the path specified.%0D%0A%2C errno %3D 3 HOT 2
- Error: Unable to find git in your PATH. .... I'm not using GIT, remove this HOT 1
- [tool_crash] FileSystemException: Cannot open file, OS Error: The system cannot find the file specified., errno = 2 HOT 2
- aot_elf_release takes a unreasonably long time to complete HOT 2
- [Impeller] iOS crashes on some devices using impeller HOT 10
- loading issues HOT 1
- [tool_crash] ProcessException: Failed to find "git" in the search path. Command: git, OS error code: 0 HOT 3
- [google_map_flutter] double-tap and hold on, then drag up/down to zoom out/in will target onCameraIdle too much on iOS HOT 1
- [tool_crash] ShaderCompilerException HOT 3
- number keyboard doesn't work in TextField after update flutter to 3.22 HOT 2
- [Linux] FocusableActionDetector not working HOT 24
- [Web] Canvaskit raise errors on latest Chrome stable version HOT 24
- Adapt flutter tools to handle workspaces:
- Crash on linux HOT 6
- RangeError: RangeError: Value not in range: 226 HOT 4
- mac-10 & mac-26 lost external connection phone device. HOT 1
- mac-24 lost external connection phone device. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter.