Skip to content

Instantly share code, notes, and snippets.

@savioserra
Created March 10, 2021 05:34
Show Gist options
  • Save savioserra/714857c17da7381455739efff632f9f4 to your computer and use it in GitHub Desktop.
Save savioserra/714857c17da7381455739efff632f9f4 to your computer and use it in GitHub Desktop.
Mouse Pointer
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: SizedBox(
height: 200,
width: 100,
child: CustomPaint(
painter: MousePointerPainter(),
),
),
),
),
);
}
}
class MousePointerPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = Colors.white
..style = PaintingStyle.fill;
final path = Path()
..moveTo(size.width / 2, 0)
..lineTo(size.width, size.height * .7)
..cubicTo(size.width, size.height * .7, size.width / 2, size.height, 0,
size.height * .7)
..close();
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(MousePointerPainter oldDelegate) => true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment