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

Flushbar Not Testable With duration #61

Open
f-hoedl opened this issue Mar 14, 2022 · 2 comments
Open

Flushbar Not Testable With duration #61

f-hoedl opened this issue Mar 14, 2022 · 2 comments

Comments

@f-hoedl
Copy link

f-hoedl commented Mar 14, 2022

Minimal reproducable example:

Widget with flushbar:

import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';

class FlushbarExample extends StatelessWidget {
  const FlushbarExample({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
      child: Text("Button"),
      onPressed: () {
        Flushbar(
          flushbarPosition: FlushbarPosition.BOTTOM,
          message: "Help",
          duration: const Duration(seconds: 3),
        ).show(context);
      },
    );
  }
}

Testclass:

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'flush_example.dart';

main() {
  testWidgets(
    "test flushbar",
    (WidgetTester tester) async {
      await tester.pumpWidget(
        const MaterialApp(
          home: Scaffold(
            body: FlushbarExample(),
          ),
        ),
      );
      var button = find.text("Button");
      expect(button, findsOneWidget);
      await tester.tap(button);
      await tester.pump(const Duration(seconds: 2));
      expect(find.text("Help"), findsOneWidget);
      await tester.pump(const Duration(seconds: 2));
    },
  );
}

Error

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown running a test:
'package:flutter/src/widgets/navigator.dart': Failed assertion: line 5021 pos 12:
'entry.currentState == _RouteLifecycle.popping ||
          (entry.hasPage && entry.currentState.index < _RouteLifecycle.pop.index)': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially
more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  [https://github.com/flutter/flutter/issues/new?template=2_bug.md]()

When the exception was thrown, this was the stack:
#2      NavigatorState.finalizeRoute (package:flutter/src/widgets/navigator.dart:5021:12)
#3      OverlayRoute.didPop (package:flutter/src/widgets/routes.dart:74:18)
#4      FlushbarRoute.didPop (package:another_flushbar/flushbar_route.dart:393:18)
#5      _RouteEntry.handlePop (package:flutter/src/widgets/navigator.dart:2896:16)
#6      NavigatorState._flushHistoryUpdates (package:flutter/src/widgets/navigator.dart:3860:22)
#7      NavigatorState.pop (package:flutter/src/widgets/navigator.dart:4902:7)
#8      FlushbarRoute._configureTimer.<anonymous closure> (package:another_flushbar/flushbar_route.dart:403:22)
#15     FakeTimer._fire (package:fake_async/fake_async.dart:316:16)
#16     FakeAsync._fireTimersWhile (package:fake_async/fake_async.dart:240:13)
#17     FakeAsync.elapse (package:fake_async/fake_async.dart:137:5)
#18     AutomatedTestWidgetsFlutterBinding.pump.<anonymous closure> (package:flutter_test/src/binding.dart:986:28)
#21     TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:71:41)
#22     AutomatedTestWidgetsFlutterBinding.pump (package:flutter_test/src/binding.dart:982:27)
#23     WidgetTester.pump.<anonymous closure> (package:flutter_test/src/widget_tester.dart:608:53)
#26     TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:71:41)
#27     WidgetTester.pump (package:flutter_test/src/widget_tester.dart:608:27)
#28     main.<anonymous closure> ([file:///C:/projects/flutter/trainingsmagnet/test/example/flush_example_test.dart:22:20]())
<asynchronous suspension>
<asynchronous suspension>
(elided 13 frames from class _AssertionError, dart:async, and package:stack_trace)

The test description was:
  test flushbar
════════════════════════════════════════════════════════════════════════════════════════════════════

Remove the Duration property in the widget and it works fine.

@devmobile-vulog
Copy link

We are encountering the same issue with flutter 2.10.3 and another_flushbar: 1.10.28

@ortemmetro
Copy link

ortemmetro commented Oct 30, 2023

Any updates on this?

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

3 participants