未验证 提交 b133df3c 编写于 作者: P Paul Berry 提交者: GitHub

Remove unnecessary `?`s from web_ui. (#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.
上级 aedacd5a
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册