0

I working on a flutter project. I want to pass list from one page to another page. but it not working out for me

List list;

    articleCall save = await Navigator.of(context).push(new MaterialPageRoute<articleCall>(
                builder: (BuildContext context) {
                  return new AddArticleDialog(list);
                },
        -----------

        class AddArticleDialog extends StatefulWidget {

            List ls=[];

          AddArticleDialog({this.ls});
          @override
          AddArticleDialogState createState() => new AddArticleDialogState();
        }

It says me the error: Too many positional arguments: 0 expected, but 1 found. Please help

Thanks, Sathish

Udara Abeythilake
  • 1,215
  • 1
  • 20
  • 31
sathish kumar
  • 1,061
  • 6
  • 16
  • 31

1 Answers1

0

When braces {} are used on constructor parameters, it will become named parameters as mentioned in the docs.

Having the constructor as

List? ls=[]; // List should be nullable since the argument is optional
AddArticleDialog({this.ls});

will require it to use an identifier for the argument.

return AddArticleDialog(ls: list);
Omatt
  • 8,564
  • 2
  • 42
  • 144