RomanBase / hand_signature

A Flutter plugin providing signature pad for drawing smooth signatures.
https://pub.dev/packages/hand_signature
MIT License
108 stars 25 forks source link

New feature: base64 method #7

Closed c0c4i closed 3 years ago

c0c4i commented 3 years ago

Hello, I'm trying to convert signature to base64 but from toImage() I'm not able to convert to base64. I don't know if there is a workaround that permit that. Thank you 👍🏻

RomanBase commented 3 years ago

Hi, image is returned as ByteData so you need to get raw data firstly -> ByteData.buffer.asUint8List(), then u can use dart:convert package to convert to base64 string.

A little example here:

import 'dart:convert';

final control = HandSignatureControl();
final image = await control.getImage();
final rawData = image.buffer.asUint8List();

final base64String = base64Encode(rawData);
c0c4i commented 3 years ago

Thank you a lot for the solution 👍🏻