Skip to content

Fix TabBar jag when user interrupts ballistic scroll#64380

Merged
fluttergithubbot merged 5 commits intoflutter:masterfrom
giantsol:tabbar_jagging
Sep 9, 2020
Merged

Fix TabBar jag when user interrupts ballistic scroll#64380
fluttergithubbot merged 5 commits intoflutter:masterfrom
giantsol:tabbar_jagging

Conversation

@giantsol
Copy link
Contributor

Description

TabBar sometimes jags when user interrupts ballistic scroll:

Almost at the end of the video, you can see a slight jagging. This happens because when user interrupts the ballistic scroll, ScrollEndNotification is called, but we don't update _controller.offset value as we do in ScrollUpdateNotification. This bug was found during another PR that I'd been working on: #60080 (comment)

cc. @chunhtai

Reproducible code
void main() {
  runApp(Main());
}

class Main extends StatefulWidget {
  Main({Key key}) : super(key: key);

  @override
  _MainState createState() => _MainState();
}

class _MainState extends State<Main> with SingleTickerProviderStateMixin {
  final List<Tab> _tabs = <Tab>[
    Tab(text: 'Tab 1'),
    Tab(text: 'Tab 2'),
    Tab(text: 'Tab 3'),
  ];

  TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(vsync: this, length: _tabs.length);
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          bottom: TabBar(
            controller: _tabController,
            tabs: _tabs,
            isScrollable: true,
            labelPadding: const EdgeInsets.symmetric(horizontal: 56),
          ),
        ),
        body: TabBarView(
          controller: _tabController,
          children: _tabs.map((Tab tab) {
            return Center(
              child: Text(tab.text),
            );
          }).toList(),
        ),
      ),
    );
  }
}

Related Issues

None

Tests

Added a test: TabController's animation value should be in sync with TabBarView's scroll value when user interrupts ballistic scroll

Checklist

Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Aug 22, 2020
@HansMuller HansMuller requested a review from chunhtai August 28, 2020 00:02
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chunhtai
Copy link
Contributor

chunhtai commented Sep 3, 2020

the device lab test keep failing, can you see if you can rebase off latest master to resolve it?

@chunhtai chunhtai closed this Sep 3, 2020
@giantsol
Copy link
Contributor Author

giantsol commented Sep 3, 2020

@chunhtai Oops, may I ask why this is closed?

@chunhtai chunhtai reopened this Sep 3, 2020
@chunhtai
Copy link
Contributor

chunhtai commented Sep 3, 2020

@giantsol sorry i clicked the wrong button

@giantsol
Copy link
Contributor Author

giantsol commented Sep 9, 2020

@chunhtai Hi! Is this waiting for the tree to go green? :)

@chunhtai
Copy link
Contributor

chunhtai commented Sep 9, 2020

@chunhtai Hi! Is this waiting for the tree to go green? :)

yes! thanks for reminding

@fluttergithubbot fluttergithubbot merged commit 389b5b6 into flutter:master Sep 9, 2020
@giantsol giantsol deleted the tabbar_jagging branch September 10, 2020 01:40
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants