Created
June 13, 2024 06:59
-
-
Save nobuh/298451842bcbb6cfa8b6da497f9cb6bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
appBar: AppBar(title: Text('CustomPaint Example')), | |
body: Center( | |
child: CustomPaint( | |
painter: MyCustomPainter(), | |
child: Container( | |
width: 400, | |
height: 400, | |
), | |
), | |
), | |
), | |
); | |
} | |
} | |
class MyCustomPainter extends CustomPainter { | |
@override | |
void paint(Canvas canvas, Size size) { | |
final paint = Paint() | |
..color = Colors.black | |
..strokeWidth = 1.0; | |
canvas.drawRect(Rect.fromPoints(Offset(0, 0), Offset(4, 4)), paint); | |
//canvas.drawLine(Offset(0, 0), Offset(size.width, size.height), paint); | |
} | |
@override | |
bool shouldRepaint(covariant CustomPainter oldDelegate) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment