CustomPaint Widget in Flutter

 import "package:flutter/material.dart";

import "package:sdreatech_learning_widget/All_widgets_Ui/customWidget.dart";

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "CustomPaint",
debugShowCheckedModeBanner: false,
theme: ThemeData(
appBarTheme: const AppBarTheme(
backgroundColor: Colors.grey,
centerTitle: true,
),
),
home: const CustomPaintPractice(),
);
}
}

class CustomPaintPractice extends StatelessWidget {
const CustomPaintPractice({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: UiHelper.customAppBar("CustomPaint"),
body: Center(
child: CustomPaint(
painter: DemoPainter(),
child: const Text(
"This is Pac-Man",
style: TextStyle(
color: Colors.black,
backgroundColor: Colors.white54,
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
),
),
);
}
}

class DemoPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
var center = size / 2;
var paint = Paint()..color = Colors.blue;
canvas.drawArc(
Rect.fromCenter(
center: Offset(center.width, center.height),
width: 250.0,
height: 250.0,
),
0.4,
2 * 3.14 - 0.8,
true,
paint,
);
}

@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
}


Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter