animate_icons
animate_icons copied to clipboard
LateInitializationError: Field 'isStart' has not been initialized.
Hello, first of all nice package.
I have a problem with using the controller, the Exception
LateInitializationError: Field 'isStart' has not been initialized.
is thrown.
class CustomAnimateIcons extends StatefulWidget {
Exercise exercise;
CustomAnimateIcons(this.exercise);
@override
_CustomAnimateIconsState createState() =>
_CustomAnimateIconsState(this.exercise);
}
class _CustomAnimateIconsState extends State<CustomAnimateIcons> {
AnimateIconController controller = AnimateIconController();
Exercise exercise;
_CustomAnimateIconsState(this.exercise);
@override
Widget build(BuildContext context) {
ExerciseProvider exerciseProvider = Provider.of(context);
List<Exercise> exerciseList = exerciseProvider.exercises;
bool isExerciseAlreadyAdded = false;
// Checks if an exercise with the exercise Id exists in the list
if ((exerciseList.singleWhere((it) => it.id == exercise.id,
orElse: () => null)) !=
null) {
isExerciseAlreadyAdded = true;
}
if (controller.isStart() && !isExerciseAlreadyAdded) {
controller.animateToEnd();
} else if (controller.isEnd() && isExerciseAlreadyAdded) {
controller.animateToStart();
}
return AnimateIcons(
startIcon: Icons.add,
endIcon: Icons.delete_outline,
controller: controller,
size: 30.0,
onStartIconPress: () {
return true;
},
onEndIconPress: () {
return true;
},
duration: Duration(milliseconds: 500),
startIconColor: AppColors.white,
endIconColor: AppColors.white,
clockwise: true,
);
}
}
Maybe I did something wrong? One thing I wonder is why there is no dispose() method for the controller? Cheers, Miro
EDIT: I just checked the example again and realized there is a late
keyword.
So it seems to be my fault by using the package wrong. But I still can't use the package as late
seems to come with null-safety and not all packages in my app are migrated yet :/ Any other way for me to use the package?
This package is discontinued, so I made another one that does the same things as this one. Feel free to have a look at it and use it. I will make what's possible to fix any issue (and also I'm looking for a mantainer)