import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:sxchnge_theme_example/main.dart'; void main() { testWidgets('consumer bundles the package font and its license', ( tester, ) async { await tester.pumpWidget(const ThemeExample()); final manifest = jsonDecode(await rootBundle.loadString('FontManifest.json')) as List; final family = manifest.cast().singleWhere( (font) => font['family'] == 'packages/sxchnge_theme/Onest', ); final asset = (family['fonts'] as List).first['asset'] as String; expect((await rootBundle.load(asset)).lengthInBytes, greaterThan(1000)); expect( await rootBundle.loadString( 'packages/sxchnge_theme/assets/fonts/OFL.txt', ), contains('SIL OPEN FONT LICENSE'), ); }); for (final mode in [ThemeMode.light, ThemeMode.dark]) { testWidgets( '$mode renders on a narrow screen with large text and accepts input', (tester) async { tester.view.physicalSize = const Size(320, 900); tester.view.devicePixelRatio = 1; tester.platformDispatcher.textScaleFactorTestValue = 2; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue); await tester.pumpWidget(ThemeExample(mode: mode)); await tester.pumpAndSettle(); expect(tester.takeException(), isNull); await tester.enterText(find.byType(TextField).first, '125.50'); expect(find.text('125.50'), findsOneWidget); await tester.ensureVisible(find.text('Continue')); await tester.pumpAndSettle(); expect(tester.takeException(), isNull); }, ); } }