getContext method

CanvasRenderingContext2D getContext(
  1. String type, {
  2. dynamic options,
})

Implementation

CanvasRenderingContext2D getContext(String type, {options}) {
  switch (type) {
    case '2d':
      if (painter.context != null) {
        painter.context!.dispose();
        painter.dispose();
      }

      context2d =
          CanvasRenderingContext2D(BindingContext(ownerView, ownerView.contextId, allocateNewBindingObject()), this);
      painter.context = context2d;

      return context2d!;
    default:
      throw FlutterError('CanvasRenderingContext $type not supported!');
  }
}