login_page.dart 完全敲完报错
来源:6-7 登录功能交互体验优化
宝慕林6515096
2024-11-04
No Directionality widget found.
Scaffold widgets require a
Directionality widget ancestor.
The specific widget that could not find a Directionality ancestor was:
Scaffold
The ownership chain for the affected widget is: "Scaffold + LoginPage + _FocusInheritedScope -_FocusSco peWithExternalFocusNode +
_FocusinheritedScope + Focus +
FocusTraversalGroup + MediaQuery
-_MediaQueryFromView <
PipelineOwnerScope + …"
Typically, the Directionality widget is introduced by the MaterialApp or WidgetsApp widget at the top of your application widget tree. It determines the ambient reading direction and is used, for example, to determine how to lay out text, how to interpret “start” and “end” values, and to resolve
EdgelnsetsDirectional,
AlignmentDirectional, and other
*Directional objects.
See also: https://docs.flutter.dev/
1回答
-
CrazyCodeBoy
2024-11-04
报错的原因是因为没有将LoginPage放在MaterialApp中使用导致的。可参考下:
MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
useMaterial3: false, //关闭Material3样式效果
primarySwatch: Colors.blue,
),
home: const LoginPage(),
);00
相似问题