0

I am working with google books in my flutter project. im trying to create a method that that will call the diffrent books URL's that i have stored in a List and call the list back using a future builder.

The list look somthing like this:

List<String> toBeReadBooksList = ['https://www.googleapis.com/books/v1/volumes?q=1086782593+isbn'];
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
PHP Pharaoh
  • 39
  • 1
  • 6

2 Answers2

0

You can do it a way that similar to this:

final url = 'https://www.googleapis.com/books/v1/volumes?q=1086782593+isbn';
final response = await http.get(url)

if (response.statusCode == 200) {
  // Here you need to parse data from response, you should replace it with your realization:
  return Data.fromJson(jsonDecode(response.body));
} else {
  throw Exception('Failed to load data from $url');
}

You can read more about how to work with requests and responses to/from the Network in Official Documentation.

fartem
  • 2,361
  • 2
  • 8
  • 20
0

Import url_launcher plugin import 'package:url_launcher/url_launcher.dart'; and in your pubspec.yaml dependecies url_launcher: ^5.7.10

add this and call it to open the selected url

_launchURL() async {
 const url = toBeReadBooksList[0];//your list url
 if (await canLaunch(url)) {
   await launch(url);
  } 
 else {
  throw 'Could not launch $url';
  }
 }
Jordan Kotiadis
  • 558
  • 6
  • 21