by @kodeazy
flutter No Directionality widget found?
I have an error as below screenshot
Below is my code
import 'package:flutter/material.dart';
void main() => runApp(const LogoApp());
class LogoApp extends StatefulWidget {
const LogoApp({super.key});
@override
State<LogoApp> createState() => _LogoAppState();
}
class _LogoAppState extends State<LogoApp> with SingleTickerProviderStateMixin {
late Animation<double> animation;
late AnimationController controller;
@override
void initState() {
super.initState();
controller =
AnimationController(duration: const Duration(seconds: 1), vsync: this);
animation = Tween<double>(begin: 0, end: 10.0).animate(controller)
..addListener(() {
setState(() {
});
// #docregion addListener
});
// #enddocregion addListener
controller.forward();
}
@override
Widget build(BuildContext context) {
return Transform.rotate(angle: 0,
child: Center(
child: Container(
child: Text("Rotation_Test"),
color: Colors.red,
height: 100,
width: 100,
),
),);
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
}
The error
is due to the reason the direction of Text()
widget is not defined.
To resolve the error specify the direction of Text()
widget like LTR or RTL
.
so replace the Text()
widget as below to solve the error.
Text("Rotation_Test", textDirection: TextDirection.ltr)