Make sure that a Hero doesn't crash in 0x0 environment (#180954)

This is my attempt to handle
https://github.com/flutter/flutter/issues/6537 for the Hero widget.

Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
This commit is contained in:
Ahmed Mohamed Sameh 2026-01-23 00:59:07 +02:00 committed by GitHub
parent 6c50f5605d
commit b6efca7440
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3906,6 +3906,20 @@ Future<void> main() async {
areCreateAndDispose,
);
});
testWidgets('Hero does not crash at zero area', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox.shrink(
child: Hero(tag: 'imageHero', child: Text('X')),
),
),
),
);
expect(tester.getSize(find.byType(Hero)), Size.zero);
});
}
class TestDependencies extends StatelessWidget {