Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'dart:async';
- import 'dart:convert';
- import 'dart:io';
- import 'package:http/http.dart' as http;
- class Pc extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return new FutureBuilder(
- future: getPcGames(),
- builder: (context, snapshot) {
- if(snapshot.hasData){
- var pcData = snapshot.data;
- return new ListView.builder(
- itemBuilder: (context, position) => new ListTile(
- title: new Text("${pcData[position]['name']}")
- ),
- itemCount: pcData.length,
- );
- } else{
- return Center(
- child: new CircularProgressIndicator(
- backgroundColor: Colors.pink
- )
- );
- }
- }
- );
- }
- }
- Future<List> getPcGames() async{
- String url = "https://api-endpoint.igdb.com/games/?fields=name,"
- "release_dates,screenshots&limit=50&order=release_dates"
- ".date:dsc&filter[platforms][eq]=48";
- http.Response response = await http.get(Uri.encodeFull(url), headers: {
- "user-key": "XXXXXXXXX",
- "Accept": "application/json"
- });
- //print(response.body);
- return json.decode(response.body);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement