When drawing, the console keeps spitting out this error message:
Another exception was thrown: Incorrect use of ParentDataWidget.
After looking a little bit around, I found that the causing line was the last part of the build function of SignatureState:
if (widget.width != null || widget.height != null) {
//IF DOUNDARIES ARE DEFINED, USE LIMITED BOX
return Center(
child: LimitedBox(
maxWidth: maxWidth,
maxHeight: maxHeight,
child: signatureCanvas,
),
);
} else {
//IF NO BOUNDARIES ARE DEFINED, USE EXPANDED
return Expanded(child: signatureCanvas);
}
Wrapping the canvas inside an Expanded widget only makes sense if the canvas is a child of Column, Row or Flex. See StackOverflow.
Although Expanded is needed when wrapped inside either of those three widgets, I think it would be better to let the user decide if the canvas should be expanded or not.
Consider the following example app:
main.dart
```dart import 'package:flutter/material.dart'; import 'package:signature/signature.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { final SignatureController controller = SignatureController(); @override Widget build(BuildContext context) { return MaterialApp( title: 'Signature Demo', home: Scaffold( appBar: AppBar(), body: Stack( children: [ Signature( controller: controller, backgroundColor: Colors.black12, ), IconButton( icon: Icon(Icons.delete), onPressed: () => controller.clear(), ) ], ), ), ); } } ```When drawing, the console keeps spitting out this error message:
After looking a little bit around, I found that the causing line was the last part of the build function of
SignatureState
:Wrapping the canvas inside an
Expanded
widget only makes sense if the canvas is a child ofColumn
,Row
orFlex
. See StackOverflow.Although
Expanded
is needed when wrapped inside either of those three widgets, I think it would be better to let the user decide if the canvas should be expanded or not.