Skip to content

Instantly share code, notes, and snippets.

@EsinShadrach
Created September 17, 2024 09:05
Show Gist options
  • Select an option

  • Save EsinShadrach/3a0bea06fd5b40bf3df1bfe4b5e8a1a3 to your computer and use it in GitHub Desktop.

Select an option

Save EsinShadrach/3a0bea06fd5b40bf3df1bfe4b5e8a1a3 to your computer and use it in GitHub Desktop.
import "package:flutter/material.dart";
class DottedBackgroundPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = Colors.white10
..style = PaintingStyle.fill;
double spacing = 10;
double dotRadius = 1.5;
for (double x = 0; x < size.width; x += spacing) {
for (double y = 0; y < size.height; y += spacing) {
canvas.drawCircle(Offset(x, y), dotRadius, paint);
}
}
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
}
@EsinShadrach

Copy link
Copy Markdown
Author

Make a background Dotted with the CustomPainter widget

@fasakinhenry

Copy link
Copy Markdown

Cool stuff. I wish I write flutter

@EsinShadrach

EsinShadrach commented Sep 18, 2024 via email

Copy link
Copy Markdown
Author

@EsinShadrach

Copy link
Copy Markdown
Author

@fasakinhenry you could always learn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment