android – Flutter: Can’t click listview item on integration test

0
46


I have an app with a listview feature with provider pattern, and it has 5 items of data. Here is my snippet code

    ListView.builder(
      key: Key("listview_portfolio"),
      itemBuilder: (context, index) =>
          _itemListPortofolio(data.items[index], context),
      itemCount: data.items.length,
    )

    Widget _itemListPortofolio(Portfolio portfolio, BuildContext context) {
      return Container(
        key: ValueKey("item_list_portfolio"),
        margin: EdgeInsets.only(bottom: 16),
        child: InkWell(

When I run this code, it doesn’t throw an error, but when I do the integration test, it throws an error when trying to click the item listview

‘package:flutter_test/src/binding.dart’: Failed assertion: line 802 pos 14: ‘_pendingExceptionDetails != null’: A test
overrode FlutterError.onError but either failed to return it to its original state, or had unexpected additional errors that it could
not handle. Typically, this is caused by using expect() before restoring FlutterError.onError.
flutter: dart:core-patch/errors_patch.dart 51:61 _AssertionError._doThrowNew

here’s my integration test class

    Future<void> tapPortfolioItem({bool scrollUp = false}) async {
        await _tester.pumpAndSettle(Duration(seconds: 5));
        final Widget itemPortfolio =
            find.byKey(ValueKey("item_list_portfolio")).evaluate().last.widget;

        await _tester.tap(find.byWidget(itemPortfolio));
      }