forked from lxm_flutter/FlutterUnit
完成空安全转换
This commit is contained in:
@@ -83,8 +83,8 @@ class PaperPainter extends CustomPainter {
|
||||
|
||||
final TouchInfo repaint;
|
||||
|
||||
PaperPainter({this.repaint}) : super(repaint: repaint);
|
||||
List<Offset> pos;
|
||||
PaperPainter({required this.repaint}) : super(repaint: repaint);
|
||||
List<Offset> pos=[];
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
@@ -118,7 +118,7 @@ class PaperPainter extends CustomPainter {
|
||||
}
|
||||
|
||||
void _drawSelectPos(Canvas canvas,Size size) {
|
||||
Offset selectPos = repaint.selectPoint;
|
||||
Offset? selectPos = repaint.selectPoint;
|
||||
if (selectPos == null) return;
|
||||
selectPos = selectPos.translate(-size.width / 2, -size.height / 2);
|
||||
canvas.drawCircle(
|
||||
|
||||
@@ -13,7 +13,6 @@ class TouchInfo extends ChangeNotifier {
|
||||
List<Offset> get points => _points;
|
||||
|
||||
set selectIndex(int value) {
|
||||
assert(value != null);
|
||||
if (_selectIndex == value) return;
|
||||
|
||||
_selectIndex = value;
|
||||
@@ -36,6 +35,6 @@ class TouchInfo extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Offset get selectPoint =>
|
||||
Offset? get selectPoint =>
|
||||
_selectIndex == -1 ? null : _points[_selectIndex];
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'dart:ui' as ui;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CircleHalo extends StatefulWidget {
|
||||
const CircleHalo({Key key}) : super(key: key);
|
||||
const CircleHalo({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CircleHaloState createState() => _CircleHaloState();
|
||||
@@ -12,7 +12,7 @@ class CircleHalo extends StatefulWidget {
|
||||
|
||||
class _CircleHaloState extends State<CircleHalo>
|
||||
with SingleTickerProviderStateMixin {
|
||||
AnimationController _ctrl;
|
||||
late AnimationController _ctrl;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
@@ -17,11 +17,11 @@ class _CurveAnimShowerState extends State<CurveAnimShower>
|
||||
with SingleTickerProviderStateMixin {
|
||||
PointData points = PointData();
|
||||
|
||||
AnimationController _ctrl;
|
||||
late AnimationController _ctrl;
|
||||
|
||||
final Duration animDuration = const Duration(milliseconds: 1000);
|
||||
|
||||
Animation<double> curveAnim;
|
||||
late Animation<double> curveAnim;
|
||||
|
||||
Map<String, Curve> maps = {
|
||||
'bounceOut': Curves.bounceOut,
|
||||
|
||||
@@ -15,7 +15,7 @@ class DrawPath extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DrawPathState extends State<DrawPath> with SingleTickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
late AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -112,10 +112,10 @@ class PaperPainter extends CustomPainter {
|
||||
|
||||
PathMetrics pms = path.computeMetrics();
|
||||
pms.forEach((pm) {
|
||||
Tangent tangent = pm.getTangentForOffset(pm.length * repaint.value);
|
||||
Tangent? tangent = pm.getTangentForOffset(pm.length * repaint.value);
|
||||
canvas.drawPath(pm.extractPath(0, pm.length * repaint.value), paint);
|
||||
canvas.drawCircle(
|
||||
tangent.position, 5, Paint()..color = Colors.blue);
|
||||
tangent?.position??Offset.zero, 5, Paint()..color = Colors.blue);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@ const double _kK = 3;
|
||||
class _SpringWidgetState extends State<SpringWidget> with SingleTickerProviderStateMixin {
|
||||
ValueNotifier<double> height = ValueNotifier(_kDefaultSpringHeight);
|
||||
|
||||
AnimationController _ctrl;
|
||||
late AnimationController _ctrl;
|
||||
|
||||
double s = 0; // 移动距离
|
||||
double laseMoveLen = 0;
|
||||
|
||||
Animation<double> animation;
|
||||
late Animation<double> animation;
|
||||
|
||||
final Duration animDuration = const Duration(milliseconds: 500);
|
||||
|
||||
@@ -98,7 +98,7 @@ class SpringPainter extends CustomPainter {
|
||||
final int count;
|
||||
final ValueListenable<double> height;
|
||||
|
||||
SpringPainter({this.count = 20, this.height}):super(repaint: height);
|
||||
SpringPainter({this.count = 20,required this.height}):super(repaint: height);
|
||||
|
||||
Paint _paint = Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
|
||||
Reference in New Issue
Block a user