Skip to content

CupertinoTabScaffold crashes when I add more tabs to it and switch to the last tab #33455

Closed

Description

@LongCatIsLooong

Expected: the below test should pass

      final List<int> tabsPainted = <int>[];
      final CupertinoTabController controller = CupertinoTabController(initialIndex: 0);

      await tester.pumpWidget(
        CupertinoApp(
          home: CupertinoTabScaffold(
            tabBar: CupertinoTabBar(
              items: List<BottomNavigationBarItem>.generate(10, tabGenerator),
            ),
            controller: controller,
            tabBuilder: (BuildContext context, int index) {
              return CustomPaint(
                child: Text('Page ${index + 1}'),
                painter: TestCallbackPainter(
                  onPaint: () { tabsPainted.add(index); }
                ),
              );
            }
          ),
        )
      );

      expect(tabsPainted, <int> [0]);

      await tester.pumpWidget(
        CupertinoApp(
          home: CupertinoTabScaffold(
            tabBar: CupertinoTabBar(
              items: List<BottomNavigationBarItem>.generate(20, tabGenerator),
            ),
            controller: controller,
            tabBuilder:
            (BuildContext context, int index) {
              return CustomPaint(
                child: Text('Page ${index + 1}'),
                painter: TestCallbackPainter(
                  onPaint: () { tabsPainted.add(index); }
                ),
              );
            }
          ),
        )
      );

      expect(tabsPainted, <int> [0, 0]);

      await tester.tap(find.text('Tab 19'));
      await tester.pump();

      // Tapping the tabs should still work.
      expect(tabsPainted, <int>[0, 0, 18]);

Actual: throws a RangeError

Activity

  1. github-actions commented on Aug 29, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  2. locked as resolved and limited conversation to collaborators on Aug 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

c: crashStack traces logged to the consolep: cupertino_uicupertino_ui package in flutter/packages

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions