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

Having a custom widget #1

Open
Y-ndm opened this issue Jul 25, 2019 · 1 comment
Open

Having a custom widget #1

Y-ndm opened this issue Jul 25, 2019 · 1 comment

Comments

@Y-ndm
Copy link

Y-ndm commented Jul 25, 2019

Hello there :)

First of all, I want to thank you for the great work you're doing. So.
I have been playing with the library a little bit and as a beginner with CostumPaint, I have found some difficulties to customize the painter as I need.
You see the pattern takes the whole screen.. and I don't know how to make it fit only in a custom widget (in my case a Container with specific width and height).. I have tried to implement (Simple example) you're providing as a child to the container, but still, it takes the whole screen.. I know there's a workaround and I'm here asking for help if possible.
Best regards and thank you for sharing this amazing library with the community,

@mattheuspirovani
Copy link

10.000 years later...

One way you can achieve this its by using a SizedBox and a Clip, like ClipRRect.

final gen = Random();
    final pattern = OverlappingCircles(
        radius: 75,
        nx: 5,
        ny: 5,
        fillColors: List.generate(
            25,
            (int i) => Color.fromARGB(
                10 + (gen.nextDouble() * 100).round(),
                50 + gen.nextInt(2) * 150,
                50 + gen.nextInt(2) * 150,
                50 + gen.nextInt(2) * 150)));

SizedBox(
          width: 200,
          height: 200,
          child: ClipRRect(
            child: CustomPaint(
                painter: FullPainter(
                    pattern: pattern, background: Colors.black)),
          ),
        )

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