Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated example code to work on ios/android AND flutter web. #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wterrill
Copy link

I opened issue #22 and thought I would give a shot at fixing it. I added the image package to pubspec.yaml in order to help with the transfer of points data from the signature pad to the saved image. This all came about because the .toByteData() is not supported for flutter web.

I hope this is useful to you. Please let me know if you need me to modify something.
Thank you very much for making the package in the first place!

@jaumard
Copy link
Contributor

jaumard commented Jun 8, 2020

Hello, sorry for the delay,

Looks good but now the example doesn't explain how to retrieve image data in base64 to be send with API at all. For me the example should stay the same (and in this case only Android/iOS compatible) but another one can be added to show web compatibility.

What do you think ?

@woshikie
Copy link
Contributor

woshikie commented Jul 17, 2020

Looks like the other signature library has implemented this with kIsWeb

Source

kIsWeb is a constant from Flutter Foundation and it should be reliable in determining if we are in Web or Mobile (iOS or Android).

Here's a quick documentation

package:flutter/src/foundation/constants.dart bool kIsWeb  

A constant that is true if the application was compiled to run on the web.

This implementation takes advantage of the fact that JavaScript does not support integers. In this environment, Dart's doubles and ints are backed by the same kind of object. Thus a double 0.0 is identical to an integer 0. This is not true for Dart code running in AOT or on the VM.

Therefore, I think it is possible to extend the current getData function such that if kIsWeb is true, we return the data using whatever is available on Flutter web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants