罗盘区域划分九宫格
This commit is contained in:
43
lib/components/grid_clip_paint.dart
Normal file
43
lib/components/grid_clip_paint.dart
Normal file
@ -0,0 +1,43 @@
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GridClipPaint extends StatelessWidget {
|
||||
const GridClipPaint({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Colors.transparent,
|
||||
alignment: Alignment.center,
|
||||
child: CustomPaint(
|
||||
// 使用CustomPaint 背景画板
|
||||
painter: ClipPainter(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ClipPainter extends CustomPainter {
|
||||
ui.Image image;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
// 创建画笔
|
||||
final Paint paint = Paint();
|
||||
canvas.drawImageRect(
|
||||
image,
|
||||
// Image(image: AssetImage("assets/images/arrow.png")),
|
||||
Rect.fromLTRB(0, 0, 700 / 3, 700 / 3),
|
||||
Rect.fromLTWH(0, 0, 700 / 3, 700 / 3),
|
||||
paint);
|
||||
// ..color = Colors.white
|
||||
// ..strokeWidth = 2;
|
||||
// 绘制线
|
||||
// canvas.drawLine(const Offset(-400, 0), const Offset(400, 0), paintLine);
|
||||
// canvas.drawLine(const Offset(0, 500), const Offset(0, -440), paintLine);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
Reference in New Issue
Block a user