4Q-s-r-o / signature

Flutter plugin that creates a canvas for writing down a signature
MIT License
252 stars 83 forks source link

SIgnatureController doesn't return Image from flutter/material.dart #95

Closed Zeroupper closed 10 months ago

Zeroupper commented 11 months ago

Hey,

I am using Flutter version 3.13.5 and have encountered an issue: the Future toImage() function returns an Image from dart:ui, not from package:flutter/material.dart. These two Image types are different, leading to an error when attempting to assign one to the other.

onTap: () async {
   final image = await _controller.toImage();
   widget.onSave(image);
},

Error:

The argument type 'Image? (where Image is defined in /home/$User/fvm/versions/3.13.5/bin/cache/pkg/sky_engine/lib/ui/painting.dart)' can't be assigned to the parameter type 'Image? (where Image is defined in /home/$User/fvm/versions/3.13.5/packages/flutter/lib/src/widgets/image.dart)'.

MartinHlavna commented 10 months ago

Hello, this is intended behavior. If you need, you can convert ui.Image (not a widget) to material Image (widget):

There were some documentation typos (missing namespace prefix ui.) I have corrected them.

onTap: () async {
   final image = await _controller.toImage();
   widget.onSave(Image.memory(
  Uint8List.view(pngBytes!.buffer)
));
},