Commit 0d152a6b authored by Dwayne Slater's avatar Dwayne Slater Committed by Adam Barth

fix DefaultTextStyle not notifying updates for some changes (#9416)

parent cc3b9147
......@@ -108,7 +108,13 @@ class DefaultTextStyle extends InheritedWidget {
}
@override
bool updateShouldNotify(DefaultTextStyle old) => style != old.style;
bool updateShouldNotify(DefaultTextStyle old) {
return style != old.style ||
textAlign != old.textAlign ||
softWrap != old.softWrap ||
overflow != old.overflow ||
maxLines != old.maxLines;
}
@override
void debugFillDescription(List<String> description) {
......
// Copyright 2017 The Chromium 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_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
void main() {
testWidgets('DefaultTextStyle changes propagate to Text', (WidgetTester tester) async {
const Text textWidget = const Text('Hello');
const TextStyle s1 = const TextStyle(
fontSize: 10.0,
fontWeight: FontWeight.w800,
height: 123.0,
);
await tester.pumpWidget(const DefaultTextStyle(
style: s1,
child: textWidget
));
RichText text = tester.firstWidget(find.byType(RichText));
expect(text, isNotNull);
expect(text.text.style, s1);
await tester.pumpWidget(const DefaultTextStyle(
style: s1,
textAlign: TextAlign.justify,
softWrap: false,
overflow: TextOverflow.fade,
maxLines: 3,
child: textWidget
));
text = tester.firstWidget(find.byType(RichText));
expect(text, isNotNull);
expect(text.text.style, s1);
expect(text.textAlign, TextAlign.justify);
expect(text.softWrap, false);
expect(text.overflow, TextOverflow.fade);
expect(text.maxLines, 3);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment