Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- // return Center(
- // child: CustomPaint(),
- // );
- return MaterialApp(
- title: 'Material App',
- home: Scaffold(
- appBar: AppBar(
- title: Text('Material App Bar'),
- ),
- body: Column(
- children: [
- // Container(child: RaisedButton()),
- Container(
- child: Stack(
- children: [
- Container(
- color: Colors.red,
- child: CustomPaint(
- painter: MyPainter3(),
- ),
- ),
- Container(
- color: Colors.red,
- child: CustomPaint(
- painter: MyPainter2(),
- ),
- ),
- Container(
- color: Colors.yellow,
- child: CustomPaint(
- painter: MyPainter(),
- ),
- ),
- // Container(
- // margin: EdgeInsets.only(top: 200),
- // height: 300,
- // color: Colors.green.withOpacity(0.4),
- // child: CustomPaint(
- // painter: MyStar(),
- // ),
- // )
- ],
- ),
- ),
- // Container(child: RaisedButton())
- ],
- ),
- ),
- );
- }
- }
- class MyStar extends CustomPainter {
- @override
- void paint(Canvas canvas, Size size) {
- // final left = 50.0;
- // final top = 100.0;
- // final right = 250.0;
- // final bottom = 200.0;
- // final rect = Rect.fromLTRB(left, top, right, bottom);
- var paint = Paint();
- // ..color = Colors.black
- // ..style = PaintingStyle.stroke
- // ..strokeWidth = 4;
- // canvas.drawRect(rect, paint);
- }
- @override
- bool shouldRepaint(covariant CustomPainter oldDelegate) {
- // TODO: implement shouldRepaint
- return false;
- }
- }
- class MyPainter3 extends CustomPainter {
- @override
- void paint(Canvas canvas, Size size) {
- var paint = Paint();
- paint.color = Colors.red;
- paint.style = PaintingStyle.fill;
- var path = Path();
- path.moveTo(0, size.height * 0.8);
- path.quadraticBezierTo(10, 400, 550, 0);
- //path.quadraticBezierTo(0, 500, 300, 0);
- canvas.drawPath(path, paint);
- }
- @override
- bool shouldRepaint(covariant CustomPainter oldDelegate) {
- return false;
- }
- }
- class MyPainter2 extends CustomPainter {
- @override
- void paint(Canvas canvas, Size size) {
- var paint = Paint();
- paint.color = Colors.yellow;
- paint.style = PaintingStyle.fill;
- var path = Path();
- path.moveTo(0, size.height * 0.8);
- path.quadraticBezierTo(10, 360, 510, 0);
- //path.quadraticBezierTo(0, 500, 300, 0);
- canvas.drawPath(path, paint);
- }
- @override
- bool shouldRepaint(covariant CustomPainter oldDelegate) {
- // TODO: implement shouldRepaint
- return false;
- }
- }
- class MyPainter extends CustomPainter {
- @override
- void paint(Canvas canvas, Size size) {
- var paint = Paint();
- paint.color = Colors.blue;
- paint.style = PaintingStyle.fill;
- var path = Path();
- path.moveTo(0, size.height * 0.8);
- path.quadraticBezierTo(0, 300, 500, 0);
- //path.quadraticBezierTo(0, 500, 300, 0);
- canvas.drawPath(path, paint);
- }
- @override
- bool shouldRepaint(covariant CustomPainter oldDelegate) {
- //throw UnimplementedError();
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement