Description
The animation works fine when I start the app. After I press back button and open the activity again I get Null error.
`import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:image_sequence_animator/image_sequence_animator.dart';
class Image_Sequence_2 extends StatefulWidget {
Image_Sequence_2() : super();
@OverRide
CarouselHistory createState() => CarouselHistory();
}
class CarouselHistory extends State<Image_Sequence_2> {
ImageSequenceAnimatorState? get imageSequenceAnimator =>
offlineImageSequenceAnimator;
ImageSequenceAnimatorState? offlineImageSequenceAnimator;
bool wasPlaying = false;
bool _useFullPaths = true;
List? _fullPathsOffline;
void onOfflineReadyToPlay(ImageSequenceAnimatorState _imageSequenceAnimator) {
offlineImageSequenceAnimator = _imageSequenceAnimator;
}
void onOfflinePlaying(ImageSequenceAnimatorState _imageSequenceAnimator) {
setState(() {});
}
@OverRide
void dispose() {
super.dispose();
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey,
appBar: AppBar(
backgroundColor: Colors.black54,
title: const Text("Demo",
style: TextStyle(fontSize: 25.0, color: Colors.teal)),
centerTitle: true,
),
body: Container(
color: Colors.black54,
height: double.infinity,
alignment: Alignment.topCenter,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Divider(
height: 20,
thickness: 5,
endIndent: 0,
color: Colors.black,
),
Container(
alignment: Alignment.center,
child: ImageSequenceAnimator(
"https://www.noorderlichtapp.nl",
"aurora_",
1,
1,
"jpg",
8,
key: Key("online"),
fps: 15,
isAutoPlay: false,
isOnline: true,
waitUntilCacheIsComplete: true,
cacheProgressIndicatorBuilder: (context, progress) {
return CircularProgressIndicator(
value: progress,
);
},
fullPaths: _useFullPaths ? _fullPathsOffline : null,
onReadyToPlay: onOfflineReadyToPlay,
onPlaying: onOfflinePlaying,
),
),
Container(
alignment: Alignment.center,
child: CupertinoSlider(
value: imageSequenceAnimator == null
? 0.0
: imageSequenceAnimator!.currentProgress,
min: 0.0,
max: imageSequenceAnimator == null
? 100.0
: imageSequenceAnimator!.totalProgress,
onChangeStart: (double value) {
wasPlaying = imageSequenceAnimator!.isPlaying;
imageSequenceAnimator!.pause();
},
onChanged: (double value) {
imageSequenceAnimator!.skip(value);
},
onChangeEnd: (double value) {
if (wasPlaying) imageSequenceAnimator!.play();
},
),
),
const Divider(
height: 20,
thickness: 5,
endIndent: 0,
color: Colors.black,
),
],
),
),
));
}
}
`