Add one DefaultTextStyle example (#122182)

Add one DefaultTextStyle example
This commit is contained in:
Bruno Leroux
2023-03-08 21:40:54 +01:00
committed by GitHub
parent b9e925ab24
commit 3b4a882b61
3 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/widgets/text/text.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('WidgetsApp test', (WidgetTester tester) async {
await tester.pumpWidget(
const example.DefaultTextStyleApp(),
);
expect(find.text('Flutter'), findsOneWidget);
final RichText text = tester.firstWidget(find.byType(RichText));
expect(text.text.style!.fontSize, 24);
expect(text.text.style!.fontWeight, FontWeight.bold);
// Because this example uses Material 3 and a light brightness, the text color
// should be the color scheme `onSurface` color.
final Color textColor = ColorScheme.fromSeed(seedColor: Colors.purple).onSurface;
expect(text.text.style!.color, textColor);
});
}