battle_background.dart 794 B

123456789101112131415161718192021222324252627282930313233
  1. import 'package:flutter/widgets.dart';
  2. import 'constant.dart';
  3. class BattleBackground extends StatelessWidget {
  4. const BattleBackground({super.key});
  5. @override
  6. Widget build(BuildContext context) {
  7. return CustomPaint(
  8. painter: _BattleBackgroundPainter(),
  9. child: const SizedBox.expand(),
  10. );
  11. }
  12. }
  13. class _BattleBackgroundPainter extends CustomPainter {
  14. @override
  15. void paint(Canvas canvas, Size size) {
  16. final paint = Paint()
  17. ..color = kBoardBackgroundColor
  18. ..style = PaintingStyle.fill;
  19. canvas.drawRRect(_getBoardRRect(size), paint);
  20. }
  21. RRect _getBoardRRect(Size size) {
  22. return RRect.fromRectAndRadius(Offset.zero & size, const Radius.circular(8));
  23. }
  24. @override
  25. bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
  26. }