Merge: Material host and controls on every platform

This commit is contained in:
2026-11-03 16:08:08 +00:00
13 changed files with 139 additions and 130 deletions
@@ -6,25 +6,25 @@ import 'package:flutter_test/flutter_test.dart';
import 'chat_test_harness.dart';
import 'fake_chat_gateway.dart';
/// The message card is also mounted under a bare `MaterialApp` (the screen's
/// iOS/macOS path). Without its own style, `Text` inherits MaterialApp's
/// "missing Material" fallback: 48px, red, monospace with a double underline.
/// iOS and macOS run the same Material app as web and Android, so the chat
/// list under an iOS `MaterialApp` renders the Material screen and controls,
/// with ordinary text rather than the "missing Material" fallback style.
void main() {
testWidgets('Cupertino empty message under MaterialApp uses normal text', (
testWidgets('iOS empty message under MaterialApp is the Material screen', (
tester,
) async {
usePhoneSurface(tester);
await pumpIosMaterialChat(tester, FakeChatGateway());
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
expect(find.byType(Scaffold), findsNothing);
expect(find.byType(Scaffold), findsWidgets);
expect(find.byType(CupertinoPageScaffold), findsNothing);
const message = 'No chat sessions on this server yet.';
expect(find.text(message), findsOneWidget);
expectNormalTextStyle(tester, message);
});
testWidgets('Cupertino load error under MaterialApp uses normal text', (
testWidgets('iOS load error under MaterialApp uses Material controls', (
tester,
) async {
usePhoneSurface(tester);
@@ -42,18 +42,19 @@ void main() {
expect(find.text(message), findsOneWidget);
expectNormalTextStyle(tester, message);
expect(find.text('No chat sessions on this server yet.'), findsNothing);
expect(find.widgetWithText(CupertinoButton, 'Retry'), findsOneWidget);
expect(find.widgetWithText(CupertinoButton, 'Retry'), findsNothing);
expect(find.text('Retry'), findsOneWidget);
});
}
/// Resolves the style actually painted for [message] and checks it is the
/// ordinary Cupertino body style rather than MaterialApp's fallback style.
/// Resolves the style actually painted for [message] and checks it is not
/// MaterialApp's "missing Material" fallback style.
void expectNormalTextStyle(WidgetTester tester, String message) {
final paragraph = tester.renderObject<RenderParagraph>(find.text(message));
final style = paragraph.text.style!;
expect(
style.fontSize,
const CupertinoThemeData().textTheme.textStyle.fontSize,
isNot(48),
reason: 'message should not use MaterialApp\'s 48px fallback style',
);
expect(style.fontFamily, isNot('monospace'));