I am getting a List of data from third-party API on one page and using the same data on another page but I don't know how to make the list iterable to access indexes in the Widget Build() method.
On this page, I am getting List.
class DetailsPage extends StatefulWidget {
List<MarkersOnMap> propertydetails;
DetailsPage({Key key, this.propertydetails})
: super(
key: key,
);
@override
_DetailsPageState createState() => _DetailsPageState();
}
This is a Build() method and I want to access index as variable on each call, currently I'm just using index [0]
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return Scaffold(
appBar: AppBar(
title: Text(widget.propertydetails[0].ePropertiesCardsList.name,
style: appBarTextStyle),
),
bottomNavigationBar: Material(
child: Container(
child: Row(
children: <Widget>[
Row(
children: [
Text(
widget.propertydetails[0].ePropertiesCardsList.price
.toString(),
style: blackBigBoldTextStyle,
),
Text(
widget.propertydetails[0].ePropertiesCardsList.status,
style: blackSmallTextStyle,
),
],
),
child: Container(
child: Text(
'Contact'),
),
),
],
),
),
),
body: ListView(
children: [
Hero(
tag: widget.propertydetails[0].ePropertiesCardsList.name,
child: slider(),
),
titleRating(),
],
),
);
}
Sending data from the page like following
_propertyFinalList(index) {
return Container(
child: Center(
child: InkWell(
onTap: () async {
var get = await future;
if (get.isNotEmpty) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailsPage(
propertydetails: get,
)),
);
}
},