Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振:小部件不是类型为';障碍物优先尺寸边缘';_Flutter_Dart_Widget_Flutter Layout_Flutter Dependencies - Fatal编程技术网

Flutter 颤振:小部件不是类型为';障碍物优先尺寸边缘';

Flutter 颤振:小部件不是类型为';障碍物优先尺寸边缘';,flutter,dart,widget,flutter-layout,flutter-dependencies,Flutter,Dart,Widget,Flutter Layout,Flutter Dependencies,我正在尝试将AppBar存储在一个变量中,以便使用多个位置 我的main.dart文件包含- final PreferredSizeWidget appBar = NavigationAppBar(_actionCall) class NavigationAppBar extends StatelessWidget with PreferredSizeWidget { final Function actionCall; NavigationAppBar(this.actionCal

我正在尝试将AppBar存储在一个变量中,以便使用多个位置

我的main.dart文件包含-

final PreferredSizeWidget appBar = NavigationAppBar(_actionCall)
class NavigationAppBar extends StatelessWidget with PreferredSizeWidget {
  final Function actionCall;

  NavigationAppBar(this.actionCall);

  @override
  Widget build(BuildContext context) {
    return Platform.isIOS ? 
    CupertinoNavigationBar(
      middle: Text(
        'ABC'
      ),
      trailing: Row(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
            GestureDetector(
              child: Icon(CupertinoIcons.add),
              onTap: () => actionCall,
            )
        ],
      ),
    ) : 
    AppBar(
      title: Text('ABC'),
      centerTitle: false,
      actions: <Widget>[
        IconButton(
          icon: Icon(Icons.add),
          onPressed: () => actionCall,
        )
      ],
    );
  }

  @override
  Size get preferredSize => Size.fromHeight(kToolbarHeight);
}
导航应用程序栏包含-

final PreferredSizeWidget appBar = NavigationAppBar(_actionCall)
class NavigationAppBar extends StatelessWidget with PreferredSizeWidget {
  final Function actionCall;

  NavigationAppBar(this.actionCall);

  @override
  Widget build(BuildContext context) {
    return Platform.isIOS ? 
    CupertinoNavigationBar(
      middle: Text(
        'ABC'
      ),
      trailing: Row(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
            GestureDetector(
              child: Icon(CupertinoIcons.add),
              onTap: () => actionCall,
            )
        ],
      ),
    ) : 
    AppBar(
      title: Text('ABC'),
      centerTitle: false,
      actions: <Widget>[
        IconButton(
          icon: Icon(Icons.add),
          onPressed: () => actionCall,
        )
      ],
    );
  }

  @override
  Size get preferredSize => Size.fromHeight(kToolbarHeight);
}

我如何解决这个问题?非常感谢您的帮助。

您是否尝试过在代码中所有适用的位置用PreferredSizeWidget替换NavigationAppBar?这对我有帮助

我的问题有一点不同,因为我必须用PreferredSizeWidget替换AppBar(而不是NavigationAppBar)


这可能与最新颤振版本中的某些更改有关。

您是否尝试在代码中的所有适用位置用PreferredSizeWidget替换NavigationAppBar?这对我有帮助

我的问题有一点不同,因为我必须用PreferredSizeWidget替换AppBar(而不是NavigationAppBar)

这可能与最新颤振版本中的某些更改有关