1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 14:58:34 +00:00

Add a Material/Cupertino adaptive application example (#69)

This commit is contained in:
xster
2019-06-10 14:14:34 -07:00
committed by Andrew Brogdon
parent 08beb69245
commit 325c5a5d2b
67 changed files with 2718 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:platform_design/main.dart';
void main() {
testWidgets('Can change platform correctly', (tester) async {
await tester.pumpWidget(MyAdaptingApp());
// The test should be able to find the drawer button.
expect(find.byIcon(Icons.menu), findsOneWidget);
// There should be a refresh button.
expect(find.byIcon(Icons.refresh), findsOneWidget);
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
await tester.pumpWidget(MyAdaptingApp());
// There should now be a large title style nav bar.
expect(find.byType(CupertinoSliverNavigationBar), findsOneWidget);
// There's a tab button for the first tab.
expect(find.byIcon(CupertinoIcons.music_note), findsOneWidget);
// The hamburger button isn't there anymore.
expect(find.byIcon(Icons.menu), findsNothing);
// Since this is a static, undo the change made in the test.
debugDefaultTargetPlatformOverride = null;
});
}