【问题标题】:The argument type 'Padding' how to solve this problem?参数类型'Padding'如何解决这个问题?
【发布时间】:2021-06-18 19:06:26
【问题描述】:

如何解决这个问题。我是新用户颤振,请任何人帮助我。

    lib/screens/main.dart:93:26: Error: The argument type 'Padding' can't be assigned to the p
    arameter type 'String'.
     - 'Padding' is from 'package:flutter/src/widgets/basic.dart' ('/C:/src/flutter/packages/f
    lutter/lib/src/widgets/basic.dart').
                      label: Padding(
                             ^
    lib/screens/main.dart:108:26: Error: The argument type 'Padding' can't be assigned to the
    parameter type 'String'.
     - 'Padding' is from 'package:flutter/src/widgets/basic.dart' ('/C:/src/flutter/packages/f
    lutter/lib/src/widgets/basic.dart').
                      label: Padding(
                             ^
    lib/screens/main.dart:120:24: Error: The argument type 'Text' can't be assigned to the par
    ameter type 'String'.
     - 'Text' is from 'package:flutter/src/widgets/text.dart' ('/C:/src/flutter/packages/flutt
    er/lib/src/widgets/text.dart').
                    label: Text(""),
                           ^
    lib/screens/main.dart:130:26: Error: The argument type 'Padding' can't be assigned to the
    parameter type 'String'.
     - 'Padding' is from 'package:flutter/src/widgets/basic.dart' ('/C:/src/flutter/packages/f
    lutter/lib/src/widgets/basic.dart').
                      label: Padding(
                             ^
    lib/screens/main.dart:145:26: Error: The argument type 'Padding' can't be assigned to the
    parameter type 'String'.
     - 'Padding' is from 'package:flutter/src/widgets/basic.dart' ('/C:/src/flutter/packages/f
    lutter/lib/src/widgets/basic.dart').
                      label: Padding(
                             ^
    /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dar
    t:276:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'Bu
    ildContext'.
     - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/p
    ackages/flutter/lib/src/widgets/framework.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'inh
    eritFromWidgetOfExactType'.
            context.inheritFromWidgetOfExactType(_ChewieControllerProvider)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/chewie_audio-1.0.0+1/lib/src/chewie_pla
    yer.dart:101:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the cl
    ass 'BuildContext'.
     - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/p
    ackages/flutter/lib/src/widgets/framework.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'inh
    eritFromWidgetOfExactType'.
            context.inheritFromWidgetOfExactType(_ChewieAudioControllerProvider)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
    
    * What went wrong:
    Execution failed for task ':app:compileFlutterBuildRelease'.
    > Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to
    get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 16s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                      77.7s
Gradle task assembleRelease failed with exit code 1

【问题讨论】:

  • 嗨 Mehedi Hasan,如果您觉得我的回答有帮助,请接受我的回答

标签: flutter dart


【解决方案1】:

您正在尝试为您的小部件提供 Padding 类型而不是 String 试试这个

Padding(
   padding: EdgeInsets.all(8),
   child: YourWidget(
         label: "a string"
   )
)

【讨论】:

    猜你喜欢
    • 2021-11-20
    • 2023-03-17
    • 2022-08-13
    • 2014-10-07
    • 1970-01-01
    • 1970-01-01
    • 2022-11-17
    相关资源
    最近更新 更多