我目前正在构建的应用程序,我需要使用嵌套路由,保持一个相同的屏幕和路由在不同的一个。我想当第二条路径被弹出时,我可以更改展开的值来填充整个屏幕。。下面是代码示例:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext conte
我有一个父部件"BookmarkedShows“和子部件"ListOfShows”。从子小部件中,当用户点击列表项时,它会打开详细信息页面。当用户从详细信息页面的书签中删除该节目时,按下back按钮时,该节目不会从列表页面中删除。即不刷新父项。我使用的是BlocBuilder。
有一些在其他问题中提到的将.then()添加到Navigator.push()方法的选项。但是,Navigator.push()发生在子组件中。如何在Navigation.pop()过程中强制刷新父BlocBuilder?
父"BookmarkedShows":
class Bookma
我得到了这个错误
E/flutter ( 9610): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: A CustRegViewModel was used after being disposed.
E/flutter ( 9610): Once you have called dispose() on a CustRegViewModel, it can no longer be used.
我有一个名为View的CustRegView,在这里,我从用户那里获取一个电话号码,并将其发送给ViewModel
我想知道当您需要从有状态窗口小部件中调用动态方法时,最佳实践是什么。
我的意思是,我有一个通用的有状态小部件,它在参数中接收函数。当我从它的状态调用它时,Lint告诉我必须避免在动态目标上调用。那我该怎么做呢?
下面是我的类目前是如何实现的
class MyStatefulWidget<T> extends extends StatefulWidget {
final Function buttonFunction;
final T functionParameter;
const MyStatefulWidget(
{Key key,
thi
在TextFormField中,您可以使用FocusScope.of(context).requestFocus(_focusNode)请求焦点。但是,如何确保相同的焦点节点处于未聚焦状态?
例如,在我的工作流程中,我希望hintText最初是X,当聚焦时是Y,当没有聚焦时返回到X。但是,如果我像下面这样使用一些常用的东西,我就不能回到X。
class TextFormFieldErrorOnLabel extends StatefulWidget {
final String hintText;
final String hintTextOnFocus;
const NewTe
这是一个非常简单的问题,我有时会看到类似于:widget.title或widget.(anything)的东西;就像AppBar widget的文本小部件中的这个例子:
class MyApp extends StatefulWidget{
// some declarations here
@override
_MyApp createState() => _MyApp();
}
class _MyApp extends State<MyApp>{
// some declaration here
@override
Widg
我有下面的代码。在initialRoute:属性中,需要调用作为异步函数的isLoggedIn()方法。我说我需要在一个await函数中调用async时出错了。但是,build方法从其父类(不是async方法)中被重写。如何在重写的方法中调用await?
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
tit
当我单击IconButton()从list movies中删除所有项目时,直到再次打开页面时才能看到更改...
有人知道我能怎么修复吗?
这是我的infoPage((“B类”)):
class InfoPage extends StatefulWidget {
int id;
int pageId;
InfoPage(this.id,this.pageId);
@override
_InfoPageState createState() => _InfoPageState(id,pageId);
}
class _InfoPageState extends Stat
在这段代码中,我希望能够进一步访问InheritedWidget类的accountID和scopeID。为了测试这一点,我编写了以下代码:
import 'package:flutter/material.dart';
class AdvisorContext extends InheritedWidget {
final int accountId;
final int scopeId;
AdvisorContext({key, this.accountId, this.scopeId, child})
: super(key: key, chil