Remove unnecessary ?s from web_ui. (flutter/engine#21444)
* Remove unnecessary `?`s from web_ui. In https://dart-review.googlesource.com/c/sdk/+/163841, dart's flow analysis is being changed so that an assignment like this: T? x = <non-nullable value>; causes `x` to be immediately promoted to type `T`. This exposed two instances in which a variable was unnecessarily given a nullable type. To avoid warnings, we need to fix these two types before https://dart-review.googlesource.com/c/sdk/+/163841 can land.
This commit is contained in:
@@ -608,11 +608,11 @@ class BitmapCanvas extends EngineCanvas {
|
||||
double x,
|
||||
double y,
|
||||
) {
|
||||
html.CanvasRenderingContext2D? ctx = _canvasPool.context;
|
||||
html.CanvasRenderingContext2D ctx = _canvasPool.context;
|
||||
x += line.left;
|
||||
final double? letterSpacing = style.letterSpacing;
|
||||
if (letterSpacing == null || letterSpacing == 0.0) {
|
||||
ctx!.fillText(line.displayText!, x, y);
|
||||
ctx.fillText(line.displayText!, x, y);
|
||||
} else {
|
||||
// When letter-spacing is set, we go through a more expensive code path
|
||||
// that renders each character separately with the correct spacing
|
||||
@@ -627,7 +627,7 @@ class BitmapCanvas extends EngineCanvas {
|
||||
final int len = line.displayText!.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
final String char = line.displayText![i];
|
||||
ctx!.fillText(char, x, y);
|
||||
ctx.fillText(char, x, y);
|
||||
x += letterSpacing + ctx.measureText(char).width!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class CanvasKit {
|
||||
external int GetWebGLContext(
|
||||
html.CanvasElement canvas, SkWebGLContextOptions options);
|
||||
external SkGrContext MakeGrContext(int glContext);
|
||||
external SkSurface MakeOnScreenGLSurface(
|
||||
external SkSurface? MakeOnScreenGLSurface(
|
||||
SkGrContext grContext,
|
||||
int width,
|
||||
int height,
|
||||
|
||||
Reference in New Issue
Block a user