Unverified Commit c6aa20d4 authored by Justin McCandless's avatar Justin McCandless Committed by GitHub

Revert "Add BuildContext parameter to TextEditingController.buildTextSpan (#72344)" (#73503)

This reverts commit 4901744e, which was a minor breaking change that I missed.  Will try to open the PR again following the breaking change process.
parent b78b1763
......@@ -31,7 +31,7 @@ class _TextSpanEditingController extends TextEditingController {
final TextSpan _textSpan;
@override
TextSpan buildTextSpan({TextStyle? style, required bool withComposing, required BuildContext context}) {
TextSpan buildTextSpan({TextStyle? style ,bool? withComposing}) {
// This does not care about composing.
return TextSpan(
style: style,
......
......@@ -185,7 +185,7 @@ class TextEditingController extends ValueNotifier<TextEditingValue> {
///
/// By default makes text in composing range appear as underlined. Descendants
/// can override this method to customize appearance of text.
TextSpan buildTextSpan({TextStyle? style , required bool withComposing, required BuildContext context}) {
TextSpan buildTextSpan({TextStyle? style , required bool withComposing}) {
assert(!value.composing.isValid || !withComposing || value.isComposingRangeValid);
// If the composing range is out of range for the current text, ignore it to
// preserve the tree integrity, otherwise in release mode a RangeError will
......@@ -2669,7 +2669,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
return widget.controller.buildTextSpan(
style: widget.style,
withComposing: !widget.readOnly,
context: context,
);
}
}
......
......@@ -5674,25 +5674,6 @@ void main() {
}),
);
});
testWidgets('TextEditingController.buildTextSpan receives build context', (WidgetTester tester) async {
final _AccentColorTextEditingController controller = _AccentColorTextEditingController('a');
const Color color = Color.fromARGB(255, 1, 2, 3);
await tester.pumpWidget(MaterialApp(
theme: ThemeData.light().copyWith(accentColor: color),
home: EditableText(
controller: controller,
focusNode: FocusNode(),
style: Typography.material2018(platform: TargetPlatform.android).black.subtitle1!,
cursorColor: Colors.blue,
backgroundCursorColor: Colors.grey,
),
));
final RenderEditable renderEditable = findRenderEditable(tester);
final TextSpan textSpan = renderEditable.text!;
expect(textSpan.style!.color, color);
});
});
testWidgets('autofocus:true on first frame does not throw', (WidgetTester tester) async {
......@@ -7169,13 +7150,3 @@ class SkipPaintingRenderObject extends RenderProxyBox {
@override
void paint(PaintingContext context, Offset offset) { }
}
class _AccentColorTextEditingController extends TextEditingController {
_AccentColorTextEditingController(String text) : super(text: text);
@override
TextSpan buildTextSpan({TextStyle? style, required bool withComposing, required BuildContext context}) {
final Color color = Theme.of(context).accentColor;
return super.buildTextSpan(style: TextStyle(color: color), withComposing: withComposing, context: context);
}
}
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