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

applyParentData #14

Open
asmith20002 opened this issue Jul 2, 2023 · 2 comments
Open

applyParentData #14

asmith20002 opened this issue Jul 2, 2023 · 2 comments

Comments

@asmith20002
Copy link

Hello,

First off, thank you for this package. I found it by accident where I was so frustrated about my app's look on Windows. This package actually solves a part of the problem. The other part on Windows is how fonts look. I wish you had a solution for that too :)

Anyway I have this custom class which overrides applyParentData on Positioned widget. When switching to pixel snap, I get this error:

The method 'applyParentData' isn't defined in a superclass of 'CustomPositioned'.
Try correcting the name to the name of an existing method, or defining a method named 'applyParentData' in a superclass.
class CustomPositioned extends Positioned
{
  const CustomPositioned({
    super.key,
    super.left,
    super.top,
    super.right,
    super.bottom,
    super.width,
    super.height,
    required super.child,
  }) : assert(left == null || right == null || width == null),
       assert(top == null || bottom == null || height == null);

	@override
	void applyParentData(RenderObject renderObject)
	{
		// Some logic codes here

		super.applyParentData(renderObject);
	}
}

For that class, I had to revert back to material/widgets.dart

@knopp
Copy link
Contributor

knopp commented Jul 2, 2023

You can import pixel snap with hide Positioned. You can also only import positioned from flutter's widgets.dart (show position) and do the subclassing. Or you can import the original widgets.dart as original and then extend original.Positioned. There are multiple ways of solving this.

@asmith20002
Copy link
Author

Yes indeed that solves the problem. I mentioned this issue because setting up this package was as easy as changing material to snap_pixel, and having to hide/show classes is a bit annoying. In fact I tested this package with a simple replace all function of my IDE and I went back and forth to test and see if it works as advertised. It would be good to keep the hassle at minimum.

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

No branches or pull requests

2 participants