App uses the Material host and controls on every platform

iOS and macOS no longer switch to the Cupertino host or Cupertino controls by
target platform; they render the same Material UI as web and Android.
Cupertino paths remain for an explicit cupertino: true host. Flutter's
automatic platform behaviours (scroll physics, text selection, back-swipe
transitions) are unchanged.
This commit is contained in:
2026-11-03 16:07:48 +00:00
parent 5f51bbf53b
commit 493e950195
13 changed files with 139 additions and 130 deletions
+19 -22
View File
@@ -7,35 +7,32 @@ import 'package:pipelines_app/ui/adaptive/platform.dart';
import 'package:pipelines_app/ui/theme/app_theme.dart';
void main() {
test('web uses Material on every host; native Apple uses Cupertino', () {
for (final platform in TargetPlatform.values) {
expect(prefersCupertino(web: true, platform: platform), isFalse);
expect(
prefersCupertino(web: false, platform: platform),
platform == TargetPlatform.iOS || platform == TargetPlatform.macOS,
);
}
test('no platform prefers the Cupertino host', () {
expect(prefersCupertino(), isFalse);
});
for (final platform in [TargetPlatform.macOS, TargetPlatform.iOS]) {
testWidgets('app and themes select the right controls on $platform', (
tester,
) async {
for (final platform in TargetPlatform.values) {
testWidgets('the app uses the Material host on $platform', (tester) async {
debugDefaultTargetPlatformOverride = platform;
addTearDown(() => debugDefaultTargetPlatformOverride = null);
await tester.pumpWidget(const MyApp());
if (kIsWeb) {
expect(find.byType(MaterialApp), findsOneWidget);
expect(find.byType(CupertinoApp), findsNothing);
expect(appLightTheme().platform, TargetPlatform.android);
expect(appDarkTheme().platform, TargetPlatform.android);
} else {
expect(find.byType(CupertinoApp), findsOneWidget);
expect(appLightTheme().platform, platform);
expect(appDarkTheme().platform, platform);
}
expect(find.byType(MaterialApp), findsOneWidget);
expect(find.byType(CupertinoApp), findsNothing);
// Native hosts keep the target platform so Flutter's automatic
// behaviours (scroll physics, text selection, back-swipe) still apply.
final expected = kIsWeb ? TargetPlatform.android : platform;
expect(appLightTheme().platform, expected);
expect(appDarkTheme().platform, expected);
await tester.pumpWidget(const SizedBox.shrink());
debugDefaultTargetPlatformOverride = null;
});
}
testWidgets('an explicit cupertino choice still builds the Cupertino host', (
tester,
) async {
await tester.pumpWidget(const MyApp(cupertino: true));
expect(find.byType(CupertinoApp), findsOneWidget);
await tester.pumpWidget(const SizedBox.shrink());
});
}