Flutter - Too many positional arguments: 0 expected, but 1 found.


I have the following screen

class ScrollablePostsScreen extends StatefulWidget {
  final String type;
  final String path;
  ScrollablePostsScreen({Key key, @required this.type})
      : super(key: key);

  @override
  _ScrollablePostsScreenState createState() => _ScrollablePostsScreenState();
}

And I am calling using the following code

ScrollablePostsScreen({type: "post"}),

but this is resulting in the following error

Too many positional arguments: 0 expected, but 1 found. Try removing the extra positional arguments, or specifying the name for named arguments.dartextra_positional_arguments_could_be_named

1 Answer

4 years ago by

Change the code to following

ScrollablePostsScreen(type: "post"),
4 years ago by Karthik Divi