flutter: 1.5.4-hotfix.2
flare_flutter: 1.5.2
Hi, I'm attempting to run basic widget tests on pages that include a FlareActor, which result in the following error:
โโโก EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The following assertion was thrown running a test:
A Timer is still pending even after the widget tree was disposed.
'package:flutter_test/src/binding.dart': Failed assertion: line 1014 pos 7:
'_currentFakeAsync.nonPeriodicTimerCount == 0'
Here is the flutter test I'm running:
import 'package:flare_flutter/flare_actor.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
Widget makeTestableWidget() {
return MaterialApp(
home: Scaffold(
body: Stack(
children: <Widget>[
FlareActor(
"assets/images/tick.flr",
alignment: Alignment.center,
fit: BoxFit.contain,
animation: "success",
),
Text('Success'),
],
),
),
);
}
void main() {
group('Flare widget', () {
testWidgets('renders correctly', (WidgetTester tester) async {
await tester.pumpWidget(makeTestableWidget());
expect(find.text('Success'), findsOneWidget);
});
});
}
Is there a suggested way to allow these tests to complete? As a workaround I've been navigating away from the page allowing the FlareActor to be disposed and the test to complete, but just wondering if there is a better way to test widgets containing FlareActors.
I believe this may be the same issue as mentioned in a comment in #69
Thanks
I am able to build the widget for testing, but it doesn't ever call initialize for the controller. So I have basic unit tests to see if there is a widget, but I can't test anything with the animations because the art board never gets initialized.
Take a look at this response in a similar issue: https://github.com/2d-inc/Flare-Flutter/issues/160#issuecomment-538603844
@luigi-rosso
That worked perfectly! Thanks so much!
@luigi-rosso how would you go about generating more flares? So i am able to initialize the flare and compare that to a golden. But I can't seem to get the animation to run again to change the tested animation.
Most helpful comment
Take a look at this response in a similar issue: https://github.com/2d-inc/Flare-Flutter/issues/160#issuecomment-538603844