Skip to content
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

Null error on reopening the activity #13

Open
bharathreddyh opened this issue Mar 22, 2022 · 0 comments
Open

Null error on reopening the activity #13

bharathreddyh opened this issue Mar 22, 2022 · 0 comments

Comments

@bharathreddyh
Copy link

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,
),
],
),
),
));
}
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant