flutter应用程序编译错误:位置参数太少:必需1,给定0。前导= IconButton(

时间:2018-12-10 00:17:02

标签: android ios flutter

我的Flutter应用程序运行正常,但开始出现多个编译错误。我也已经厌倦了带有样板代码的新项目,但是它也会引发同样的错误。任何帮助都会很棒。我已经厌倦了升级和清理项目,但没有成功。

flutter: The following _CompileTimeError was thrown building AppBar(dirty, state: _AppBarState#61196):
flutter: 'package:flutter/src/material/app_bar.dart': error: line 399 pos 29:
flutter: file:///Users/bradmurray/Developer/flutter/packages/flutter/lib/src/material/app_bar.dart:399:29:
flutter: Error: Too few positional arguments: 1 required, 0 given.
flutter:         leading = IconButton(
flutter:                             ^
flutter:         leading = IconButton(
flutter:                             ^
flutter:
[Screen shot][1]


  [1]: https://i.stack.imgur.com/ZUO2Y.png

I am also getting this error form time to time:

   Compiler message:
file:///Users/UserName/Developer/flutter/packages/flutter/lib/src/material/icon_button.dart:87:20: Error: Duplicated parameter name 'icon'.
    @required this.icon,
                   ^^^^
file:///Users/UserName/Developer/flutter/packages/flutter/lib/src/material/icon_button.dart:82:25: Context: Other parameter named 'icon'.
  const IconButton(Icon icon, {
                        ^^^^
file:///Users/UserName/Developer/flutter/packages/flutter/lib/src/widgets/basic.dart:3726:23: Error: Duplicated parameter name 'text'.
  Row(Text text, Text text, {
                      ^^^^
file:///Users/UserName/Developer/flutter/packages/flutter/lib/src/widgets/basic.dart:3726:12: Context: Other parameter named 'text'.
.......

1 个答案:

答案 0 :(得分:1)

IconButton要求您传递一个Icon小部件和一个onPressed回叫。