Last active
July 3, 2019 23:14
-
-
Save suragch/33fa53eda8f79bdaec74a0b6348d2138 to your computer and use it in GitHub Desktop.
CustomPaint setup
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( | |
body: HomeWidget(), | |
), | |
); | |
} | |
} | |
class HomeWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Center( | |
child: CustomPaint( // <-- CustomPaint widget | |
size: Size(300, 300), | |
painter: MyPainter(), | |
), | |
); | |
} | |
} | |
class MyPainter extends CustomPainter { // <-- CustomPainter class | |
@override | |
void paint(Canvas canvas, Size size) { | |
// <-- Insert your painting code here. | |
} | |
@override | |
bool shouldRepaint(CustomPainter old) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment