add animate live widget

master
张萌 3 years ago
parent d724abf915
commit 776e770804

@ -1 +1 @@
/Users/akufe/fvm/versions/2.0.0
/Users/zhangmeng/fvm/versions/2.0.2

@ -1,3 +1,4 @@
{
"flutterSdkVersion": "2.0.0"
"flutterSdkVersion": "2.0.2",
"flavors": {}
}

@ -3,3 +3,7 @@
## [0.0.1] - Add AnimatedRotate
* AnimatedRotate.
## [0.0.2] -Add AnimateLiveWidget
* AnimateLiveWidget

@ -0,0 +1,67 @@
import 'package:animated_collection/src/animate_live_parinter.dart';
import 'package:flutter/material.dart';
class LiveAnimate extends StatefulWidget {
final double size;
final double strokeWidth;
final int place;
final Duration delay;
final Duration duration;
const LiveAnimate(
{Key? key,
required this.size,
required this.strokeWidth,
required this.place,
required this.delay,
required this.duration})
: super(key: key);
@override
_LiveAnimateState createState() => _LiveAnimateState();
}
class _LiveAnimateState extends State<LiveAnimate>
with TickerProviderStateMixin {
late AnimationController _controller;
late Animation _animation;
@override
void initState() {
_controller = AnimationController(vsync: this, duration: widget.duration)
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
_controller.reverse();
}
})
..addStatusListener((status) {
if (status == AnimationStatus.dismissed) {
_controller.forward();
}
});
_animation = CurveTween(curve: Curves.easeInOut).animate(_controller);
Future.delayed(widget.delay, () async {
await _controller.forward();
});
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _animation,
builder: (context, child) {
return CustomPaint(
painter: LiveAnimateIcon(
_animation.value, widget.strokeWidth, widget.place),
size: Size(widget.size / 3, widget.size * 0.5),
);
});
}
}

@ -0,0 +1,50 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class LiveAnimateIcon extends CustomPainter {
final double strokeWidth;
final double value;
final int palce;
LiveAnimateIcon(
this.value,
this.strokeWidth,
this.palce,
);
@override
void paint(Canvas canvas, Size size) {
double offset = size.height * (value * 0.3 + 0.2);
Paint paint = Paint()
..strokeWidth = this.strokeWidth
..style = PaintingStyle.stroke
..strokeCap = StrokeCap.round
..color = Colors.white;
Path path = Path();
path.moveTo(
this.palce == 0
? size.width * 0.8
: this.palce == 2
? size.width * 0.2
: size.width / 2,
offset);
path.lineTo(
this.palce == 0
? size.width * 0.8
: this.palce == 2
? size.width * 0.2
: size.width / 2,
size.height - offset);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return true;
}
@override
bool shouldRebuildSemantics(covariant CustomPainter oldDelegate) {
return true;
}
}

@ -0,0 +1,49 @@
import 'package:animated_collection/src/animate_live_builder.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class LiveAnimateWidget extends StatefulWidget {
final double? size;
final double? strokeWidth;
const LiveAnimateWidget({Key? key, this.size, this.strokeWidth})
: super(key: key);
@override
_LiveAnimateWidgetState createState() => _LiveAnimateWidgetState();
}
class _LiveAnimateWidgetState extends State<LiveAnimateWidget> {
@override
Widget build(BuildContext context) {
return Container(
width: widget.size ?? 50.w,
height: widget.size ?? 50.w,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular((widget.size ?? 50.w) / 2),
),
child: Row(
children: [
LiveAnimate(
size: widget.size ?? 50.w,
duration: Duration(milliseconds: 800),
strokeWidth: widget.strokeWidth ?? 5.w,
place: 0,
delay: Duration(milliseconds: 0)),
LiveAnimate(
size: widget.size ?? 50.w,
duration: Duration(milliseconds: 800),
strokeWidth: widget.strokeWidth ?? 5.w,
place: 1,
delay: Duration(milliseconds: 200)),
LiveAnimate(
size: widget.size ?? 50.w,
duration: Duration(milliseconds: 800),
strokeWidth: widget.strokeWidth ?? 5.w,
place: 2,
delay: Duration(milliseconds: 400)),
],
));
}
}

@ -5,49 +5,49 @@ packages:
dependency: transitive
description:
name: async
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
flutter:
@ -55,6 +55,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_screenutil:
dependency: "direct main"
description:
name: flutter_screenutil
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.0+2"
flutter_test:
dependency: "direct dev"
description: flutter
@ -64,21 +71,21 @@ packages:
dependency: transitive
description:
name: matcher
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
sky_engine:
@ -90,56 +97,56 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
sdks:

@ -11,7 +11,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_screenutil: ^5.0.0
dev_dependencies:
flutter_test:
sdk: flutter

Loading…
Cancel
Save