Commit 2b34d78
authored
Fixes [M3 TabBar indicator animation broken both when swiping or
tapping](flutter#160631)
### Description
This refactors the elastic `Tab` animation. Added additional tests that
follows the elastic animation frame by frame and generates a golden
file.
### Code Sample
<details>
<summary>expand to view the code sample</summary>
```dart
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@OverRide
Widget build(BuildContext context) {
// timeDilation = 10;
return MaterialApp(
home: ScrollConfiguration(
behavior: ScrollConfiguration.of(context).copyWith(dragDevices: <PointerDeviceKind>{
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
}),
child: Directionality(
textDirection: TextDirection.ltr,
child: DefaultTabController(
length: 8,
child: Scaffold(
appBar: AppBar(
bottom: const TabBar(
isScrollable: true,
tabAlignment: TabAlignment.start,
tabs: <Widget>[
Tab(text: 'Home'),
Tab(text: 'Search'),
Tab(text: 'Add'),
Tab(text: 'Favorite'),
Tab(text: 'The longest text...'),
Tab(text: 'Short'),
Tab(text: 'Longer text...'),
Tab(text: 'Profile'),
],
),
),
body: const TabBarView(
children: <Widget>[
Center(child: Text('Page')),
Center(child: Text('Page')),
Center(child: Text('Page')),
Center(child: Text('Page')),
Center(child: Text('Page')),
Center(child: Text('Page')),
Center(child: Text('Page')),
Center(child: Text('Page')),
],
),
),
),
),
),
);
}
}
```
</details>
### Before (`timeDilation = 10`)
https://github.com/user-attachments/assets/4f69f94b-0bcf-4813-b49f-06ff411435ca
### After (`timeDilation = 10`)
https://github.com/user-attachments/assets/65801c1c-d28f-4b42-870a-7140d5d3c4c3
| Before Test Results | After Test Results |
| --------------- | --------------- |
| <img
src="https://github.com/user-attachments/assets/72ae9fbe-fef9-44a0-9b86-5a4c31fd39cf"
/> | <img
src="https://github.com/user-attachments/assets/2545f35e-ac03-495d-a33b-72b9bc71299b"
/> |
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 14d4abb commit 2b34d78
File tree
5 files changed
+435
-130
lines changed- examples/api/test/material/tabs
- packages/flutter
- lib/src/material
- test/material
5 files changed
+435
-130
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
| 484 | + | |
484 | 485 | | |
485 | 486 | | |
486 | 487 | | |
| |||
507 | 508 | | |
508 | 509 | | |
509 | 510 | | |
| 511 | + | |
510 | 512 | | |
511 | 513 | | |
512 | 514 | | |
| |||
583 | 585 | | |
584 | 586 | | |
585 | 587 | | |
586 | | - | |
587 | 588 | | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
592 | 603 | | |
| 604 | + | |
593 | 605 | | |
594 | 606 | | |
595 | 607 | | |
596 | 608 | | |
597 | | - | |
| 609 | + | |
598 | 610 | | |
599 | 611 | | |
600 | 612 | | |
| |||
627 | 639 | | |
628 | 640 | | |
629 | 641 | | |
630 | | - | |
| 642 | + | |
631 | 643 | | |
632 | 644 | | |
633 | 645 | | |
634 | 646 | | |
635 | | - | |
| 647 | + | |
636 | 648 | | |
637 | 649 | | |
638 | 650 | | |
639 | 651 | | |
640 | | - | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
641 | 664 | | |
642 | 665 | | |
643 | 666 | | |
644 | | - | |
| 667 | + | |
645 | 668 | | |
646 | 669 | | |
647 | | - | |
648 | | - | |
649 | | - | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
650 | 675 | | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
651 | 683 | | |
652 | | - | |
653 | | - | |
654 | | - | |
| 684 | + | |
| 685 | + | |
655 | 686 | | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
664 | 705 | | |
665 | 706 | | |
666 | 707 | | |
| |||
1517 | 1558 | | |
1518 | 1559 | | |
1519 | 1560 | | |
| 1561 | + | |
1520 | 1562 | | |
1521 | 1563 | | |
1522 | 1564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
1700 | 1699 | | |
1701 | 1700 | | |
1702 | 1701 | | |
1703 | | - | |
1704 | | - | |
1705 | | - | |
1706 | | - | |
1707 | | - | |
1708 | | - | |
1709 | | - | |
1710 | | - | |
1711 | | - | |
1712 | | - | |
1713 | | - | |
1714 | | - | |
1715 | | - | |
1716 | | - | |
1717 | | - | |
1718 | | - | |
1719 | | - | |
1720 | | - | |
1721 | | - | |
1722 | | - | |
1723 | | - | |
1724 | | - | |
1725 | | - | |
1726 | | - | |
1727 | | - | |
1728 | | - | |
1729 | 1702 | | |
1730 | | - | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
1731 | 1712 | | |
1732 | 1713 | | |
1733 | 1714 | | |
1734 | 1715 | | |
1735 | | - | |
1736 | | - | |
1737 | | - | |
1738 | | - | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
1739 | 1723 | | |
1740 | 1724 | | |
1741 | 1725 | | |
| |||
0 commit comments