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

There is a problem uploading json data to firestore. #29

Closed schosdas closed 1 year ago

schosdas commented 2 years ago

My code is as follows. After drawing, I'm going to convert the data I drew into Json and upload it to Firestore. (And I'm going to get it back later.)

Container(
                      width: _screenWidth ?? 525, 
                      height: _screenHeight ?? 736,
                      color: Colors.transparent,
                      child: HandSignature(
                        control: signControl,
                        type: SignatureDrawType.shape,

                        onPointerUp: () async {
                          final drawJson = signControl.toMap();

                          // TODO firebase upload
                          await FirebaseFirestore.instance
                              .collection(COL_ROOMS)
                              .doc(widget.roomKey)
                              .collection(COL_DRAW)
                              .doc()
                              .set(drawJson);
                        },
                      ),

However, the following error is printed when uploading.

Nested arrays are not supported

There seems to be a problem with the json data. Is there a way to do this?

RomanBase commented 2 years ago

Hey, this problem is not related to this package. Exported json is valid, but as error says: Lib using nested arrays and Firestore don't support them (we have list of lines and every line has list of vertices). In fact we can update json, but then someone else will have problems with structure or other DB..

But my recommendation is: don't store RAW data to no-sql DB (whenever you can). Raw data will create complex document and you can easily run out of free read/write Firestore quota. But you have multiple options how to deal with it:

Also onPointerUp event is not best place to store data, because this will be called multiple times during drawing process.