The widget on which setState() or markNeedsBuild() was called was:

我是写了一个跳转的方法,由于刚学,代码不小心写成了这样:

        onTap: () {
            showDialog(
              context: context,
              builder: (BuildContext context) {
                if(item==9){//设置页面
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) => SettingsPage()),
                  );
                }else{
                  return new AlertDialog(
                    title: new Text(
                      'ListViewAlert',
                      style: new TextStyle(
                        color: Colors.black54,
                        fontSize: 18.0,
                      ),
                    ),
                    content: new Text('您选择的item内容为:$titleItem'),
                  );
                }
              },
            );
        },

我的Navigator放在了Builder里面,就会有下面的错误:

The widget on which setState() or markNeedsBuild() was called was:_第1张图片

希望大家也注意下,多检查下代码。

 

 

你可能感兴趣的:(The widget on which setState() or markNeedsBuild() was called was:)