What does too many positional argument mean in Flutter?

Issue

Dart Analysis Toolbar

When I wrote this code in Android Studio, that is what came up in my dart analysis toolbar:
The code I wrote
How do I prevent this?

Solution

You are missing a ) bracket add it before the semicolon .

This link explains the about positional and named arguments . And The process you are trying is not a good practice. You need to breakdown the widgets so that it becomes easier to maintain.

Try as follows:

    void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.blueGrey,
        appBar: AppBar(
          title: const Text('I am rich'),
          backgroundColor: Colors.blueGrey[900],
        ),
        body: Center(
          child: Image.asset('images/diamond.png'),
        ),
      ),
    );
  }
}

Answered By – Nbn

Answer Checked By – Senaida (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.