package but the project that I am trying to run was made on an older version of simple animations, so I don't have much knowledge about this package but I'm trying to mimic what the old version did:
import 'package:flutter/material.dart';
import 'package:simple_animations/simple_animations.dart';
class FadeAnimation extends StatelessWidget {
final double delay;
final Widget child;
FadeAnimation(this.delay, this.child);
@override
Widget build(BuildContext context) {
final tween = MovieTween();
tween.tween('opacity', Tween(begin: 0.0, end: 1.0), duration: Duration(milliseconds: 500));
tween.tween('translateY', Tween(begin: -30.0, end: 0.0), duration: Duration(milliseconds: 500), curve: Curves.easeOut);
return PlayAnimationBuilder(
delay: Duration(milliseconds: (500 * delay).round()),
duration: tween.duration,
tween: tween,
child: child,
builder: (context, movie, child) => Opacity(
opacity: child['opacity'], // The method '[]' can't be unconditionally invoked because the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null check to the target ('!').
child: Transform.translate(
offset: Offset(0, child["translateY"]), child: child), // The method '[]' can't be unconditionally invoked because the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null check to the target ('!').
),
);
}
}
I get the errors on lines 23 and 25 that basically state the same thing, "The method '[]' can't be unconditionally invoked because the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null check to the target ('!')." And I don't know how to fix this please help.
Old Version
Поэтому я использую[code]simple_animations: ^5.0.2[/code] package but the project that I am trying to run was made on an older version of simple animations, so I don't have much knowledge about this package but I'm trying to mimic what the old version did: [code]import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart';
class FadeAnimation extends StatelessWidget { final double delay; final Widget child;
FadeAnimation(this.delay, this.child);
@override Widget build(BuildContext context) { final tween = MovieTween();
return PlayAnimationBuilder( delay: Duration(milliseconds: (500 * delay).round()), duration: tween.duration, tween: tween, child: child, builder: (context, movie, child) => Opacity( opacity: child['opacity'], // The method '[]' can't be unconditionally invoked because the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null check to the target ('!'). child: Transform.translate( offset: Offset(0, child["translateY"]), child: child), // The method '[]' can't be unconditionally invoked because the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null check to the target ('!'). ), ); } }
[/code] I get the errors on lines 23 and 25 that basically state the same thing, "The method '[]' can't be unconditionally invoked because the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null check to the target ('!')." And I don't know how to fix this please help. Old Version [code]import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart';
class FadeAnimation extends StatelessWidget { final double delay; final Widget child;