Skip to content

Add TextHeightBehavior argument for DefaultTextStyle.merge #153178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for DefaultTextStyle.merge
  • Loading branch information
kawaijoe committed Aug 14, 2024
commit fb6feb006bbc295d40e1c2d476eebfdf3ac3e940
45 changes: 45 additions & 0 deletions packages/flutter/test/widgets/text_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,51 @@ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'semantics_tester.dart';

void main() {
testWidgets('DefaultTextStyle.merge correctly merges arguments', (WidgetTester tester) async {
DefaultTextStyle defaultTextStyle = const DefaultTextStyle.fallback();

await tester.pumpWidget(
MaterialApp(
home: DefaultTextStyle(
style: const TextStyle(color: Colors.black, fontSize: 20),
textAlign: TextAlign.left,
softWrap: false,
overflow: TextOverflow.ellipsis,
maxLines: 2,
textWidthBasis: TextWidthBasis.longestLine,
textHeightBehavior: const TextHeightBehavior(applyHeightToFirstAscent: false),
child: DefaultTextStyle.merge(
style: const TextStyle(color: Colors.red, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
softWrap: true,
overflow: TextOverflow.fade,
maxLines: 3,
textWidthBasis: TextWidthBasis.parent,
textHeightBehavior: const TextHeightBehavior(applyHeightToLastDescent: false),
child: Builder(
builder: (BuildContext context) {
defaultTextStyle = DefaultTextStyle.of(context);
return const Text('Text');
},
),
),
),
),
);

expect(defaultTextStyle.style, const TextStyle(
color: Colors.red,
fontSize: 20,
fontWeight: FontWeight.bold,
));
expect(defaultTextStyle.textAlign, TextAlign.center);
expect(defaultTextStyle.softWrap, true);
expect(defaultTextStyle.overflow, TextOverflow.fade);
expect(defaultTextStyle.maxLines, 3);
expect(defaultTextStyle.textWidthBasis, TextWidthBasis.parent);
expect(defaultTextStyle.textHeightBehavior, const TextHeightBehavior(applyHeightToLastDescent: false));
});

testWidgets('Text respects media query', (WidgetTester tester) async {
await tester.pumpWidget(MediaQuery.withClampedTextScaling(
minScaleFactor: 1.3,
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy