-
Notifications
You must be signed in to change notification settings - Fork 30.4k
Make const work with LayoutBuilder Widget #145537
Copy link
Copy link
Closed
Labels
c: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework team
Metadata
Metadata
Assignees
Labels
c: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework team
Use case
I tried to use const with responsive widgets like using the
LayoutBuilderwidget or using if statement withMediaQuery.of(context).size.widthbut these const widgets still rebuild. I check it by using print in theWidget build(BuildContext context)I think it is good to make const work for the responsive widget. Many widgets are used in many screen sizes.
For an example:
The console will print rebuild every time you change screen size between 500 units.
Proposal
Make the
constwidget work withLayoutBuilderor other responsive widgets.