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

Bug report: Incorrect use of ParentDataWidget #49

Closed
h7x4 opened this issue Dec 7, 2021 · 1 comment
Closed

Bug report: Incorrect use of ParentDataWidget #49

h7x4 opened this issue Dec 7, 2021 · 1 comment
Labels
has pull request Issue should be fixed after merging pull request
Milestone

Comments

@h7x4
Copy link
Contributor

h7x4 commented Dec 7, 2021

Consider the following example app:

main.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:

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.

@MartinHlavna MartinHlavna added the has pull request Issue should be fixed after merging pull request label Dec 15, 2021
@MartinHlavna MartinHlavna added this to the 5.0.0 milestone Dec 17, 2021
@MartinHlavna
Copy link
Member

Released in 5.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has pull request Issue should be fixed after merging pull request
Projects
None yet
Development

No branches or pull requests

2 participants