como va? como soy nuevo en Flutter y no hay muchos ejemplos, quería saber como podría seleccionar un ítem de mi ListView y pasar los datos a una nueva pantalla para hacer el perfil del objeto seleccionado.
El código de mi ListView es:
class Page extends StatelessWidget {
@required
final Text title; //Titulo a mostrar
@required
final Future<List<Negocio>> list;
Page({this.title, this.list});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: this.title,
),
body: FutureBuilder<List<Negocio>>(
future: list,
builder: (context, snapshot) {
if (snapshot.hasData) {
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
ListTile(
title: Text(snapshot.data[index].title),
onTap: () {
//ACA SUPONGO QUE IRIA ITEM SELECCIONADO.
},
);
Negocio negocio = snapshot.data[index];
return NegocioItem(
negocio: negocio,
);
});
} else if (snapshot.hasError) {
return Text("${snapshot.error}");
}
// By default, show a loading spinner
return Center(
child: CircularProgressIndicator(),
);
},
),
);
}
}
class NegocioItem extends StatelessWidget {
@required
final Negocio negocio;
NegocioItem({this.negocio});
@override
Widget build(BuildContext context) {
return GestureDetector(
//onTap: _launchURL,
child: Card(
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Image.network(
negocio.imageUrl,
width: 90,
),
Expanded(
child: Text(
negocio.title,
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 22),
textAlign: TextAlign.center,
),
),
],
),
Text(negocio.description),
/* Align(
alignment: Alignment.centerRight,
child: Text(
negocio.fecha,
textAlign: TextAlign.right,
style: TextStyle(fontSize: 15, color: Colors.green),
),
)*/
],
),
),
),
);
}
}