Drawing on flutter canvas

sourav mandal
May 7, 2021

--

import 'package:flutter/material.dart';class CrosswordGame extends StatefulWidget {
@override
_CrosswordGameState createState() => _CrosswordGameState();
}
class _CrosswordGameState extends State<CrosswordGame> {
``@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
child: CustomPaint(
child: Container(),
painter: ShapePainter(),
),
),
);
}
}
class ShapePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
// TODO: implement paint

}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
// TODO: implement shouldRepaint
return null;
}
}

Rectangle

var paint1 = Paint()
..color = Color(0xff995588)
..style = PaintingStyle.fill;
canvas.drawRect(Offset(100, 100) & const Size(200, 150), paint1);

Circle

var paint1 = Paint()
..color = Color(0xffaa44aa)
..style = PaintingStyle.fill;
canvas.drawCircle(Offset(200, 200), 100, paint1);

Triangle

var path = Path();
path.lineTo(size.width, 0);
path.lineTo(size.height, size.width);
path.close();
canvas.drawPath(path, paint);

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

sourav mandal
sourav mandal

Written by sourav mandal

just a coder who forgets things so makes blogs so he can remember later

No responses yet

Write a response