Skip to content

Type safety #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
64 changes: 32 additions & 32 deletions example/lib/same_variable_multiple_animations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,58 @@ import 'package:flutter_sequence_animation/flutter_sequence_animation.dart';

class SameVariableAnimationPage extends StatefulWidget {
@override
_SameVariableAnimationPageState createState() => new _SameVariableAnimationPageState();
_SameVariableAnimationPageState createState() =>
new _SameVariableAnimationPageState();
}

class _SameVariableAnimationPageState extends State<SameVariableAnimationPage> with SingleTickerProviderStateMixin{

class _SameVariableAnimationPageState extends State<SameVariableAnimationPage>
with SingleTickerProviderStateMixin {
static final colorTag = SequenceAnimationTag<Color?>();
static final widthTag = SequenceAnimationTag<double>();
static final heightTag = SequenceAnimationTag<double>();

late AnimationController controller;
late SequenceAnimation sequenceAnimation;


@override
void initState() {
super.initState();
controller = new AnimationController(vsync: this, duration: const Duration(seconds: 5));
controller = new AnimationController(
vsync: this, duration: const Duration(seconds: 5));

sequenceAnimation = new SequenceAnimationBuilder()
.addAnimatable(
.addAnimatable(
animatable: new ColorTween(begin: Colors.red, end: Colors.yellow),
from: const Duration(seconds: 0),
from: const Duration(seconds: 0),
to: const Duration(seconds: 4),
tag: "color"
).addAnimatable(
tag: colorTag)
.addAnimatable(
animatable: new Tween<double>(begin: 50.0, end: 300.0),
from: const Duration(seconds: 0),
from: const Duration(seconds: 0),
to: const Duration(milliseconds: 3000),
tag: "width",
curve: Curves.easeIn
).addAnimatable(
tag: widthTag,
curve: Curves.easeIn)
.addAnimatable(
animatable: new Tween<double>(begin: 300.0, end: 100.0),
from: const Duration(milliseconds: 3000),
from: const Duration(milliseconds: 3000),
to: const Duration(milliseconds: 3700),
tag: "width",
curve: Curves.decelerate
).addAnimatable(
tag: widthTag,
curve: Curves.decelerate)
.addAnimatable(
animatable: new Tween<double>(begin: 50.0, end: 300.0),
from: const Duration(seconds: 0),
from: const Duration(seconds: 0),
to: const Duration(milliseconds: 3000),
tag: "height",
curve: Curves.ease
).addAnimatable(
tag: heightTag,
curve: Curves.ease)
.addAnimatable(
animatable: new Tween<double>(begin: 300.0, end: 450.0),
from: const Duration(milliseconds: 3000),
from: const Duration(milliseconds: 3000),
to: const Duration(milliseconds: 3800),
tag: "height",
curve: Curves.decelerate
).animate(controller);


tag: heightTag,
curve: Curves.decelerate)
.animate(controller);
}


Future<Null> _playAnimation() async {
try {
await controller.forward().orCancel;
Expand Down Expand Up @@ -86,9 +87,9 @@ class _SameVariableAnimationPageState extends State<SameVariableAnimationPage> w
builder: (context, child) {
return new Center(
child: new Container(
color: sequenceAnimation["color"].value,
height: sequenceAnimation["height"].value,
width: sequenceAnimation["width"].value,
color: sequenceAnimation.get(colorTag).value,
height: sequenceAnimation.get(heightTag).value,
width: sequenceAnimation.get(widthTag).value,
),
);
},
Expand All @@ -97,5 +98,4 @@ class _SameVariableAnimationPageState extends State<SameVariableAnimationPage> w
),
);
}

}
10 changes: 5 additions & 5 deletions example/lib/sequence_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SequencePage extends StatefulWidget {
}

class _SequencePageState extends State<SequencePage> with SingleTickerProviderStateMixin{

static final colorTag = SequenceAnimationTag<Color?>();

late AnimationController controller;
late SequenceAnimation sequenceAnimation;
Expand All @@ -25,19 +25,19 @@ class _SequencePageState extends State<SequencePage> with SingleTickerProviderSt
animatable: new ColorTween(begin: Colors.red, end: Colors.yellow),
from: const Duration(seconds: 0),
to: const Duration(seconds: 2),
tag: "color"
tag: colorTag
).addAnimatable(
animatable: new ColorTween(begin: Colors.yellow, end: Colors.blueAccent),
from: const Duration(seconds: 2),
to: const Duration(seconds: 4),
tag: "color",
tag: colorTag,
curve: Curves.easeOut
).addAnimatable(
animatable: new ColorTween(begin: Colors.blueAccent, end: Colors.pink),
// animatable: new Tween<double>(begin: 200.0, end: 40.0),
from: const Duration(seconds: 5),
to: const Duration(seconds: 6),
tag: "color",
tag: colorTag,
curve: Curves.fastOutSlowIn
).animate(controller);

Expand Down Expand Up @@ -75,7 +75,7 @@ class _SequencePageState extends State<SequencePage> with SingleTickerProviderSt
builder: (context, child) {
return new Center(
child: new Container(
color: sequenceAnimation["color"].value,
color: sequenceAnimation.get(colorTag).value,
height: 200.0,
width: 200.0,
),
Expand Down
31 changes: 19 additions & 12 deletions example/lib/staggered_animation_replication.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ class StaggeredAnimationReplication extends StatefulWidget {

class _StaggeredAnimationReplicationState extends State<StaggeredAnimationReplication> with SingleTickerProviderStateMixin{

static final opacityKey = SequenceAnimationTag<double>();
static final widthKey = SequenceAnimationTag<double>();
static final heightKey = SequenceAnimationTag<double>();
static final paddingKey = SequenceAnimationTag<EdgeInsets>();
static final borderRadiusKey = SequenceAnimationTag<BorderRadius>();
static final colorKey = SequenceAnimationTag<Color?>();

late AnimationController controller;
late SequenceAnimation sequenceAnimation;

Expand All @@ -24,37 +31,37 @@ class _StaggeredAnimationReplicationState extends State<StaggeredAnimationReplic
from: Duration.zero,
to: const Duration(milliseconds: 200),
curve: Curves.ease,
tag: "opacity"
tag: opacityKey
).addAnimatable(
animatable: new Tween<double>(begin: 50.0, end: 150.0),
from: const Duration(milliseconds: 250),
to: const Duration(milliseconds: 500),
curve: Curves.ease,
tag: "width"
tag: widthKey
).addAnimatable(
animatable: new Tween<double>(begin: 50.0, end: 150.0),
from: const Duration(milliseconds: 500),
to: const Duration(milliseconds: 750),
curve: Curves.ease,
tag: "height"
tag: heightKey
).addAnimatable(
animatable: new EdgeInsetsTween(begin: const EdgeInsets.only(bottom: 16.0), end: const EdgeInsets.only(bottom: 75.0),),
from: const Duration(milliseconds: 500),
to: const Duration(milliseconds: 750),
curve: Curves.ease,
tag: "padding"
tag: paddingKey
).addAnimatable(
animatable: new BorderRadiusTween(begin: new BorderRadius.circular(4.0), end: new BorderRadius.circular(75.0),),
from: const Duration(milliseconds: 750),
to: const Duration(milliseconds: 1000),
curve: Curves.ease,
tag: "borderRadius"
tag: borderRadiusKey
).addAnimatable(
animatable: new ColorTween(begin: Colors.indigo[100], end: Colors.orange[400],),
from: const Duration(milliseconds: 1000),
to: const Duration(milliseconds: 1500),
curve: Curves.ease,
tag: "color"
tag: colorKey
).animate(controller);
}

Expand All @@ -66,20 +73,20 @@ class _StaggeredAnimationReplicationState extends State<StaggeredAnimationReplic

Widget _buildAnimation(BuildContext context, Widget? child) {
return new Container(
padding: sequenceAnimation["padding"].value,
padding: sequenceAnimation.get(paddingKey).value,
alignment: Alignment.bottomCenter,
child: new Opacity(
opacity: sequenceAnimation["opacity"].value,
opacity: sequenceAnimation.get(opacityKey).value,
child: new Container(
width: sequenceAnimation["width"].value,
height: sequenceAnimation["height"].value,
width: sequenceAnimation.get(widthKey).value,
height: sequenceAnimation.get(heightKey).value,
decoration: new BoxDecoration(
color: sequenceAnimation["color"].value,
color: sequenceAnimation.get(colorKey).value,
border: new Border.all(
color: Colors.indigo[300]!,
width: 3.0,
),
borderRadius: sequenceAnimation["borderRadius"].value,
borderRadius: sequenceAnimation.get(borderRadiusKey).value,
),
),
),
Expand Down
Loading