Reland: Set IconButton.visualDensity default to VisualDensity.standard (#109432)

* Revert "Revert "Set `IconButton.visualDensity` default to `VisualDensity.standard` (#109349)" (#109421)"

Co-authored-by: Qun Cheng <quncheng@google.com>
This commit is contained in:
Qun Cheng
2022-08-18 09:46:13 -07:00
committed by GitHub
parent 981bdf5476
commit 79013b2be8
9 changed files with 117 additions and 43 deletions

View File

@@ -19,10 +19,6 @@ class IconButtonToggleApp extends StatelessWidget {
theme: ThemeData(
colorSchemeSeed: const Color(0xff6750a4),
useMaterial3: true,
// Desktop and web platforms have a compact visual density by default.
// To see buttons with circular background on desktop/web, the "visualDensity"
// needs to be set to "VisualDensity.standard".
visualDensity: VisualDensity.standard,
),
title: 'Icon Button Types',
home: const Scaffold(

View File

@@ -13,32 +13,32 @@ void main() {
);
expect(find.text('Hero Sample'), findsOneWidget);
await tester.tap(find.byType(Container));
await tester.tap(find.byType(example.BoxWidget));
await tester.pump();
Size heroSize = tester.getSize(find.byType(Container));
Size heroSize = tester.getSize(find.byType(example.BoxWidget));
// Jump 25% into the transition (total length = 300ms)
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container));
heroSize = tester.getSize(find.byType(example.BoxWidget));
expect(heroSize.width.roundToDouble(), 103.0);
expect(heroSize.height.roundToDouble(), 60.0);
// Jump to 50% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container));
heroSize = tester.getSize(find.byType(example.BoxWidget));
expect(heroSize.width.roundToDouble(), 189.0);
expect(heroSize.height.roundToDouble(), 146.0);
// Jump to 75% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container));
heroSize = tester.getSize(find.byType(example.BoxWidget));
expect(heroSize.width.roundToDouble(), 199.0);
expect(heroSize.height.roundToDouble(), 190.0);
// Jump to 100% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container));
heroSize = tester.getSize(find.byType(example.BoxWidget));
expect(heroSize, const Size(200.0, 200.0));
expect(find.byIcon(Icons.arrow_back), findsOneWidget);
@@ -47,25 +47,25 @@ void main() {
// Jump 25% into the transition (total length = 300ms)
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container));
heroSize = tester.getSize(find.byType(example.BoxWidget));
expect(heroSize.width.roundToDouble(), 199.0);
expect(heroSize.height.roundToDouble(), 190.0);
// Jump to 50% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container));
heroSize = tester.getSize(find.byType(example.BoxWidget));
expect(heroSize.width.roundToDouble(), 189.0);
expect(heroSize.height.roundToDouble(), 146.0);
// Jump to 75% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container));
heroSize = tester.getSize(find.byType(example.BoxWidget));
expect(heroSize.width.roundToDouble(), 103.0);
expect(heroSize.height.roundToDouble(), 60.0);
// Jump to 100% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container));
heroSize = tester.getSize(find.byType(example.BoxWidget));
expect(heroSize, const Size(50.0, 50.0));
});
}

View File

@@ -16,30 +16,30 @@ void main() {
await tester.tap(find.byType(ElevatedButton));
await tester.pump();
Size heroSize = tester.getSize(find.byType(Container).first);
Size heroSize = tester.getSize(find.byType(example.BoxWidget).first);
expect(heroSize, const Size(50.0, 50.0));
// Jump 25% into the transition (total length = 300ms)
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).first);
heroSize = tester.getSize(find.byType(example.BoxWidget).first);
expect(heroSize.width.roundToDouble(), 171.0);
expect(heroSize.height.roundToDouble(), 73.0);
// Jump to 50% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).first);
heroSize = tester.getSize(find.byType(example.BoxWidget).first);
expect(heroSize.width.roundToDouble(), 371.0);
expect(heroSize.height.roundToDouble(), 273.0);
// Jump to 75% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).first);
heroSize = tester.getSize(find.byType(example.BoxWidget).first);
expect(heroSize.width.roundToDouble(), 398.0);
expect(heroSize.height.roundToDouble(), 376.0);
// Jump to 100% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).first);
heroSize = tester.getSize(find.byType(example.BoxWidget).first);
expect(heroSize, const Size(400.0, 400.0));
expect(find.byIcon(Icons.arrow_back), findsOneWidget);
@@ -48,25 +48,25 @@ void main() {
// Jump 25% into the transition (total length = 300ms)
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).first);
heroSize = tester.getSize(find.byType(example.BoxWidget).first);
expect(heroSize.width.roundToDouble(), 398.0);
expect(heroSize.height.roundToDouble(), 376.0);
// Jump to 50% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).first);
heroSize = tester.getSize(find.byType(example.BoxWidget).first);
expect(heroSize.width.roundToDouble(), 371.0);
expect(heroSize.height.roundToDouble(), 273.0);
// Jump to 75% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).first);
heroSize = tester.getSize(find.byType(example.BoxWidget).first);
expect(heroSize.width.roundToDouble(), 171.0);
expect(heroSize.height.roundToDouble(), 73.0);
// Jump to 100% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).first);
heroSize = tester.getSize(find.byType(example.BoxWidget).first);
expect(heroSize, const Size(50.0, 50.0));
});
@@ -79,30 +79,30 @@ void main() {
await tester.tap(find.byType(ElevatedButton));
await tester.pump();
Size heroSize = tester.getSize(find.byType(Container).last);
Size heroSize = tester.getSize(find.byType(example.BoxWidget).last);
expect(heroSize, const Size(50.0, 50.0));
// Jump 25% into the transition (total length = 300ms)
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).last);
heroSize = tester.getSize(find.byType(example.BoxWidget).last);
expect(heroSize.width.roundToDouble(), 133.0);
expect(heroSize.height.roundToDouble(), 133.0);
// Jump to 50% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).last);
heroSize = tester.getSize(find.byType(example.BoxWidget).last);
expect(heroSize.width.roundToDouble(), 321.0);
expect(heroSize.height.roundToDouble(), 321.0);
// Jump to 75% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).first);
heroSize = tester.getSize(find.byType(example.BoxWidget).first);
expect(heroSize.width.roundToDouble(), 398.0);
expect(heroSize.height.roundToDouble(), 376.0);
// Jump to 100% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).last);
heroSize = tester.getSize(find.byType(example.BoxWidget).last);
expect(heroSize, const Size(400.0, 400.0));
expect(find.byIcon(Icons.arrow_back), findsOneWidget);
@@ -111,25 +111,25 @@ void main() {
// Jump 25% into the transition (total length = 300ms)
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).last);
heroSize = tester.getSize(find.byType(example.BoxWidget).last);
expect(heroSize.width.roundToDouble(), 386.0);
expect(heroSize.height.roundToDouble(), 386.0);
// Jump to 50% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).last);
heroSize = tester.getSize(find.byType(example.BoxWidget).last);
expect(heroSize.width.roundToDouble(), 321.0);
expect(heroSize.height.roundToDouble(), 321.0);
// Jump to 75% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).last);
heroSize = tester.getSize(find.byType(example.BoxWidget).last);
expect(heroSize.width.roundToDouble(), 133.0);
expect(heroSize.height.roundToDouble(), 133.0);
// Jump to 100% into the transition.
await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms
heroSize = tester.getSize(find.byType(Container).last);
heroSize = tester.getSize(find.byType(example.BoxWidget).last);
expect(heroSize, const Size(50.0, 50.0));
});
}