简体   繁体   中英

2 positional argument(s) expected, but 0 found. Flutter

I'm new in Flutter and i traed to do a note app with Flutter & Firebase. But I have this problem to redirect a SpeedDial button to other page. Do someone know what is the problem? I tried to put data and ref as arguments but I have the problem too.

This is the menu code, here I want to redirect the user to notes page with this SpeedDial

SpeedDialChild(
            child: const Icon(
              Icons.text_fields_rounded,
              color: violeta,
            ),
            label: 'notes',
            labelStyle: TextStyle(color: violeta),
            backgroundColor: amarillo,
            onTap: (() {
              Navigator.of(context).push(MaterialPageRoute(
                builder: ((context) => notas()),
              ));
            })),

And this is the part of the notes page where I declared the arguments to connect the new note with flutter

class notes extends StatefulWidget {
  late String tituloTexto;
  late String notaTexto;
  late String nomCuaderno;
  late final Map data;
  late final DocumentReference ref;

  notas(this.data, this.ref);

  @override
  State<notas> createState() => _notasState();
}

I really apreciette if someone can help me.

Thank you! <3

you need to put the arguments into notas() in Navigator.of(context).push(MaterialPageRoute(builder: ((context) => notas()) .

because the notas constructor needs 2 arguments notas(this.data, this.ref);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM