import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
void main() {
runApp(MyApp(
products: List<String>.generate(500, (i) => "Product List: $i"),
));
}
class MyApp extends StatelessWidget {
final List<String> products;
MyApp({Key key,
@required this.products}) : super(key: key);
@override Widget build(BuildContext context) {
final appTitle = 'Flutter Long List Demo';
return MaterialApp(
title: appTitle,
home: Scaffold(
appBar: AppBar(
title: Text(appTitle),
),
body: ListView.builder(
itemCount: products.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(fetchAlbum()),
);
},
),
),
);
}
Future<String> fetchAlbum() async {
//return http.get('
https://jsonplaceholder.typicode.com/albums/1');
// return "a";
/////////////////////////////////////////////////////////
final response = await http.get('
https://jsonplaceholder.typicode.com/albums/1');
if (response.statusCode == 200) {
// If the server did return a 200 OK response,
// then parse the JSON.
return response.body;
} else {
// If the server did not return a 200 OK response,
// then throw an exception.
throw Exception('Failed to load album');
}
//////////////////
var Response;
return Response.fromStream(http.get('
http://92.124.144.204:2727/anek'));
}
}