Как отправить аргументы на другой экран? флаттер - PullRequest
0 голосов
/ 02 февраля 2020

Я пытаюсь отправить аргументы «участника» на другой экран, я могу сделать это с помощью ListView и загрузить список событий, но он не работает с участниками так же, как сейчас, если список работает, но когда я нажимаю и хочу увидеть информацию об "участнике", все выходит в ноль:

В этой части я создаю участника и создаю список, чтобы иметь возможность его визуализировать, и с помощью давая сигнал, я отправляю информацию об этом (по мне)

        Widget _crearListadoParticipantes() {
      return FutureBuilder<List<Participantes>>(
        future: eventosProvider.cargarParticipantes(evento, participantes),
        builder: (context, snapshot) {
          if ( snapshot.hasData ) {
            final participantes = snapshot.data;
            return ListView.builder(
              itemCount: participantes.length,
              itemBuilder: (context, i) {
                return _crearParticipante(context, participantes[i], evento);
              }
            );
          } else if (snapshot.hasError){
            return Center(child: Text("${snapshot.error}"));
          } else {  
            return Center( child: CircularProgressIndicator());
          }
        },
      );
    }

    Widget _crearParticipante(BuildContext context, Participantes participantes, EventoModel evento) {
      return Padding(
        padding: EdgeInsets.all(12.0),
        child: GestureDetector(
          child: RichText(
            softWrap: false,
            text: TextSpan(
              style: TextStyle(
                color: Colors.black,
                fontFamily: "Lato_LightItalic",
                fontStyle: FontStyle.italic,
                fontSize: 20.0,
                fontWeight: FontWeight.w400
              ),
              children: [
                TextSpan(text: '     '+'${participantes.numero}',
                  style: TextStyle(
                    fontWeight: FontWeight.w600
                  )
                ),
                TextSpan(text: "           "),
                TextSpan(text: '${participantes.apellido} ${participantes.nombre}',)
              ],
            ),
          ),
          onTap: () => Navigator.pushNamed(context, 'destalleParticipante', arguments: evento),
        ),
      );
    }

И именно здесь я должен получить аргументы участника, которому я нажал, но, как я уже сказал, возвращается ноль

    class DetalleParticipante extends StatefulWidget {

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

    class _DetalleParticipanteState extends State<DetalleParticipante> {

      final eventosProvider = new EventosProvider();

      EventoModel evento = new EventoModel();
      Participantes participantes = new Participantes();

      @override
      Widget build(BuildContext context) {

        final EventoModel eventoData = ModalRoute.of(context).settings.arguments;
        if ( eventoData != null ) {
          evento = eventoData;
        }
          print(participantes.nombre);
        return Scaffold(
          appBar: PreferredSize(
            preferredSize: Size.fromHeight(0),
            child: AppBar(
              backgroundColor: Color(0xFF249FE2),
            ),
          ),
          backgroundColor: Colors.white,
          body:  Container(
            color: Colors.white,
            child: Column(
              children: <Widget>[
                _encabezadoParticipante(context, AssetImage("assets/icon/info_corredor.png"), participantes, evento),
              ],
            ),
          ),
        );
      }

      Widget _backBottom() {
return FloatingActionButton(
  elevation: 0.0,
  backgroundColor: Colors.white,
  child: Icon(
    Icons.arrow_back,
    size: 45.0,
    color: Colors.black,
  ),
  onPressed: (){
    Navigator.pop(context);
  },
);

}

      Widget _encabezadoParticipante(BuildContext context, AssetImage image, Participantes participantes, EventoModel evento) {
        return Container(
          color: Colors.grey[600],
          child: Padding(
            padding: const EdgeInsets.all(10.0),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: <Widget>[
                _backBottom(),
                Flexible(
                  child: Padding(
                    padding: EdgeInsets.all(8.0),
                    child: Text('${participantes.apellido}',
                    textAlign: TextAlign.center,
                      maxLines: 3,
                      softWrap: true,
                      style: TextStyle(                
                        color: Colors.white,
                        fontFamily: "Lato",
                        fontStyle: FontStyle.italic,
                        fontSize: 30.0,
                        fontWeight: FontWeight.bold
                      ),
                    ),
                  ),
                ),
                Image(image: image,
                fit: BoxFit.cover,
                ),
              ],
            ),
          ),
        );
      }

    }
...