Flutter (Dart) only gives me a warning instead of an error during a missing required function argument

Stefan

Why does Flutter only give me a warning instead of an error during a missing required function argument?

Let's take this code for example:

      FlatButton(
        color: Colors.red,
        onPressed: () {
          doSomething();
        },
      ),

The FlatButton requires a @required Widget child and @required VoidCallback onPressed argument. The child is missing here, but it still compiles and only gives me a warning.

Are @Required arguments not that important to give an error? Can somebody explain me why this only gives a warning instead of an error?

jamesdlin

@required, as designated by the @, is just an annotation (provided from package:meta) and is not a language feature. It tells tools such as the Dart analyzer to generate a warning, but neglecting to supply the missing argument is still technically legal, so it will compile.

You can make the Dart analyzer treat it as an error instead of as a warning, but again, that won't help if you neglect to run the analyzer.

Note that the null-safe version of Dart adds a new required keyword that replaces the @required annotation, and that therefore will be a proper language feature and will generate compilation errors if the argument is omitted.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Code gives missing 1 required positional argument error

Function in Class error: TypeError: function() missing 1 required positional argument:

Bash shell script function gives "find: missing argument to `-exec'" error

"@required" annotation as error instead of warning

Calling function from different class gives TypeError: missing 1 required positional argument

Passing a function with void pointer as argument gives warning

I am giving passing the argument into function still it gives error code missing argument while adding linked list

Missing 1 Required Keyword-Only Argument

Adding a SwiftUI view to a UIKit app gives me a `Missing argument for parameter 'font' in call` error

Function call missing argument list warning

Warning: missing argument error on putting stores in database

function model() missing 1 required positional argument

Function missing 1 required positional argument

missing 1 required positional argument for a function

Function missing 1 required positional argument: 'lst'

List Storing constructer gives me an error in Dart

NeutralinoJS: error: missing required argument 'name'

"TYPE ERROR MISSING 1 REQUIRED POSITIONAL ARGUMENT"

Why calling a singleton class Qt Message Handler member function gives error: missing argument list?

Missing argument 1 for function error

Flutter / Dart Error: The argument type 'Null Function(Key)' can't be assigned to the parameter type 'void Function(Object)'

Type Error missing 1 required positional argument: 'self' calling the class function

Error while calling python function, TypeError: returnbook() missing 1 required positional argument: 'self'

Python using lamda function error missing 1 required positional argument: 'event'

TypeError: get() missing 1 required positional argument: 'url' error in function SOLVED

Got "function missing required argument 'month' (pos 2)" error while adding a DateField to models.py

Error - function missing required argument 'month' (pos 2), is displayed when trying to fetch time in fixed format

"'key' is required, but there's no corresponding argument" flutter error

Trying to setParent during update function gives error

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive