I am getting below exception while running flutter code in android studio.
I/flutter ( 5360): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ I/flutter ( 5360): The following assertion was thrown building Text("xyz"): I/flutter ( 5360): No Directionality widget found. I/flutter ( 5360): RichText widgets require a Directionality widget ancestor. I/flutter ( 5360): The specific widget that could not find a Directionality ancestor was: I/flutter ( 5360): RichText(softWrap: wrapping at box width, maxLines: unlimited, text: "xyz") I/flutter ( 5360): The ownership chain for the affected widget is: I/flutter ( 5360): RichText ← Text ← Center ← Container ← [root] I/flutter ( 5360): Typically, the Directionality widget is introduced by the MaterialApp or WidgetsApp widget at the I/flutter ( 5360): top of your application widget tree. It determines the ambient reading direction and is used, for I/flutter ( 5360): example, to determine how to lay out text, how to interpret "start" and "end" values, and to resolve I/flutter ( 5360): EdgeInsetsDirectional, AlignmentDirectional, and other *Directional objects.
Code snippet:
import 'package:flutter/material.dart';
void main() {
runApp(
Container(child: Center(child: Text("xyz"))),
);
}
I am not sure why this exception says
I/flutter ( 5360): Typically, the Directionality widget is introduced by the MaterialApp or WidgetsApp widget at the ...
Because in flutter everything is a widget, so any widget should work for us.