Reputation: 6820
I have widget that called PhotosList
which is a statelessWidget I am trying to send $_deviceId
to this widget but I already send data to the widget and I don't want to upset the widget.
class PhotosList extends StatelessWidget {
final Photo photos;
FlutterRadioPlayer _flutterRadioPlayer = new FlutterRadioPlayer();
PhotosList({Key key, this.photos}) : super(key: key);
@override
Widget build(BuildContext context) {
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
// childAspectRatio: MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height / 4), //childAspectRatio: 200,
),
scrollDirection: Axis.horizontal,
itemCount: photos.data.length,
itemBuilder: (context, index) {
return RaisedButton(
padding: const EdgeInsets.all(0),
textColor: Colors.white,
color: Colors.black,
onPressed: () async { await _flutterRadioPlayer.setUrl(photos.data[index].listenlive, "true");
},
child: CachedNetworkImage(
imageUrl: photos.data[index].imageurl,
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
),
);
// return Image.network(photos.data[index].imageurl, width: 80.0, height: 80.0,);
},
);
}
}
We use the following to load it.
FutureBuilder<Photo>(
future: fetchPhotos(http.Client()),
builder: (context, snapshot) {
if (snapshot.hasError) print(snapshot.error);
return snapshot.hasData
? Expanded(child: PhotosList(photos: snapshot.data))
: Center(child: CircularProgressIndicator());
},
),
Which works - but now I want to send $_DeviceID with that request.
I have already set $_deviceId
. From my understanding I need to send it like:
PhotosList(photos: snapshot.data, uuid: $_deviceId))
and then in PhotosList put
class PhotosList extends StatelessWidget {
final Photo photos;
final String uuid;
FlutterRadioPlayer _flutterRadioPlayer = new FlutterRadioPlayer();
PhotosList({Key key, this.photos}) : super(key: key);
@override
Widget build(BuildContext context) {
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
// childAspectRatio: MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height / 4), //childAspectRatio: 200,
),
scrollDirection: Axis.horizontal,
itemCount: photos.data.length,
itemBuilder: (context, index) {
return RaisedButton(
padding: const EdgeInsets.all(0),
textColor: Colors.white,
color: Colors.black,
onPressed: () async { await _flutterRadioPlayer.setUrl(photos.data[index].listenlive+'?uuid'+uuid, "true");
},
child: CachedNetworkImage(
imageUrl: photos.data[index].imageurl,
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
),
);
// return Image.network(photos.data[index].imageurl, width: 80.0, height: 80.0,);
},
);
}
}
The error I got was
Error: No named parameter with the name 'uuid'.
? Expanded(child: PhotosList(photos: snapshot.data,uuid:$_deviceId))
Upvotes: 0
Views: 239
Reputation: 121
you should do it like this : PhotosList({Key key, this.photos, this.uuid}) : super(key: key);
Upvotes: 1