Fix runtime type errors when running with canvaskit (flutter/engine#16312)

* fix runtime type errors when running with canvaskit
This commit is contained in:
vsmenon 2020-02-04 10:32:51 -08:00 committed by GitHub
parent 233ed5dbe5
commit 4c9598cdbe
2 changed files with 11 additions and 7 deletions

View File

@ -58,7 +58,7 @@ class SkiaFontCollection {
final String asset = fontAsset['asset'];
_loadingFontBuffers.add(html.window
.fetch(assetManager.getAssetUrl(asset))
.then((dynamic fetchResult) => fetchResult.arrayBuffer()));
.then(_getArrayBuffer));
}
}
@ -69,9 +69,13 @@ class SkiaFontCollection {
// Download Roboto and add it to the font buffers.
_loadingFontBuffers.add(html.window
.fetch(_robotoUrl)
.then((dynamic fetchResult) => fetchResult.arrayBuffer()));
.then(_getArrayBuffer));
}
}
Future<ByteBuffer> _getArrayBuffer(dynamic fetchResult) {
return fetchResult.arrayBuffer().then<ByteBuffer>((x) => x as ByteBuffer);
}
js.JsObject skFontMgr;
}

View File

@ -110,10 +110,10 @@ class Surface {
..position = 'absolute'
..width = '${logicalSize.width.ceil()}px'
..height = '${logicalSize.height.ceil()}px';
final js.JsObject glContext = canvasKit
final int glContext = canvasKit
.callMethod('GetWebGLContext', <html.CanvasElement>[htmlCanvas]);
final js.JsObject grContext =
canvasKit.callMethod('MakeGrContext', <js.JsObject>[glContext]);
canvasKit.callMethod('MakeGrContext', [glContext]);
final js.JsObject skSurface =
canvasKit.callMethod('MakeOnScreenGLSurface', <dynamic>[
grContext,
@ -135,7 +135,7 @@ class Surface {
return false;
}
canvasKit.callMethod('setCurrentContext', <js.JsObject>[_surface.context]);
canvasKit.callMethod('setCurrentContext', [_surface.context]);
_surface.getCanvas().flush();
return true;
}
@ -144,7 +144,7 @@ class Surface {
/// A Dart wrapper around Skia's SkSurface.
class SkSurface {
final js.JsObject _surface;
final js.JsObject _glContext;
final int _glContext;
SkSurface(this._surface, this._glContext);
@ -153,7 +153,7 @@ class SkSurface {
return SkCanvas(skCanvas);
}
js.JsObject get context => _glContext;
int get context => _glContext;
int width() => _surface.callMethod('width');
int height() => _surface.callMethod('height');