4Q-s-r-o / signature

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

Orientation change clears canvas on iOS #10

Closed kmusham closed 4 years ago

kmusham commented 5 years ago

Hi, One of our customers reported that changing the device orientations wipes or clears the signature they have added. This issue is happening only on iOS, android works fine. Do you think it is a bug in the libraries, if so, do you have any recommendations for us until the issue is fixed? Thanks

MartinHlavna commented 5 years ago

Hi, we will look on this. However if it is iOS only problem help would be welcomed.

ioxua commented 4 years ago

If you have a StatefulWidget, a possible workaround for this is saving the state yourself. As a sidenote, I was able to reproduce the error on an Android app, so it is not iOS exclusive

class MyWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _MyWidgetState();
}

class _MyWidgetState extends State<MyWidget> {
  List<Point> _currentPoints;

  @override
  Widget build(BuildContext context) {
    Signature signature = Signature(
      points: _currentPoints ?? [],
      onChanged: (newPoints) {
        setState(() {
          _currentPoints = newPoints;
        });
      },
    );
  }
}
MartinHlavna commented 4 years ago

This is fixed in 3.0.0 as data are stored in controller not in widget itself