I'm testing a widget that includes the following code (adapted from here):
await tester.pumpWidget(
MediaQuery(
data: const MediaQueryData(devicePixelRatio: 1.0),
child: FocusScope(
node: focusScopeNode,
autofocus: true,
child: Row(
children: <Widget>[
MongolEditableText(
key: key1,
controller: TextEditingController(),
focusNode: focusNode,
style: const TextStyle(fontSize: 9),
cursorColor: cursorColor,
),
MongolEditableText(
key: key2,
controller: TextEditingController(),
focusNode: focusNode,
style: const TextStyle(fontSize: 9),
cursorColor: cursorColor,
),
],
),
),
),
);
But when I do I get the following exception:
Horizontal RenderFlex with multiple children has a null textDirection, so the layout order is undefined.
I tried adding a textDirection
parameter to my custom widget that I'm testing but that didn't change anything.
I found the answer here, so I'm adding an answer below.