-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#51110Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: 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 Flutterengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamOwned by Engine teamtriaged-engineTriaged by Engine teamTriaged by Engine team
Description
Use case
When painting to a canvas I find myself reusing very similar Paint object with just one field tweaked. For example, multiple Paints with the same stroke/strokeWidth, but with a different colour. Making a decision to change the strokeWidth could be error prone. For example:
final item1Stroke = Paint()
..color = Colors.red
..style = PaintingStyle.stroke
..isAntiAlias = false
..strokeWidth = 10;
final item2Stroke = Paint()
..color = Colors.green
..style = PaintingStyle.stroke
..isAntiAlias = false
..strokeWidth = 10;
final item3Stroke = Paint()
..color = Colors.blue
..style = PaintingStyle.stroke
..isAntiAlias = false
..strokeWidth = 10;Proposal
Instead add a copyWith method, for example:
final defaultStroke = Paint()
..style = PaintingStyle.stroke
..isAntiAlias = false
..strokeWidth = 10;
final item1Fill = defaultStroke.copyWith(
color: Colors.red
);
final item2Fill = defaultStroke.copyWith(
color: Colors.blue
);
final item3Fill = defaultStroke.copyWith(
color: Colors.green
);This proposal was filed previously: #40497 but that issue was closed without explaination, and at that time had 21 thumbs up (if that's any kind of signal).
Solido and timmaffett
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: 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 Flutterengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamOwned by Engine teamtriaged-engineTriaged by Engine teamTriaged by Engine team