Cubit仅适用于无状态小部件吗?
我正在尝试应用此状态管理,但我无法实施它。如果我使用无状态小部件,我可以轻松地实施它,但是说明它很复杂,我无法实现它。在哪里实施肘?这是我的代码零件=>
class MaintenanceScreen extends StatefulWidget {
int? locId;
MaintenanceScreen({required this.locId, Key? key}) : super(key: key);
@override
_MaintenanceScreenState createState() => _MaintenanceScreenState();
}
class _MaintenanceScreenState extends State<MaintenanceScreen> {
final colFr = FrenchColors();
I am trying to apply this state management but i cannot implement it. If I use stateless widget, i can easily implement it but stateful it is complicated and i cannot achieve it. Where to implement cubits? Here is my code part =>
class MaintenanceScreen extends StatefulWidget {
int? locId;
MaintenanceScreen({required this.locId, Key? key}) : super(key: key);
@override
_MaintenanceScreenState createState() => _MaintenanceScreenState();
}
class _MaintenanceScreenState extends State<MaintenanceScreen> {
final colFr = FrenchColors();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您是说要访问
locid
in_MaintenancesCreenstate
简而言之,您可以在构建功能内使用
widget.locid
,而颤动将与小部件类绑定。if you mean you want to access
locId
in_MaintenanceScreenState
simply you can use
widget.locId
inside the build function and flutter will bind this with the widget class.