Removed HTTP and used DIO for network calls

This commit is contained in:
jideguru
2020-01-19 02:39:48 +01:00
parent 25cfe1ce94
commit 5fa1d9a0d3
8 changed files with 54 additions and 12 deletions

View File

@@ -47,8 +47,7 @@ Please star⭐ the repo if you like what you see😉.
|**Provider**| State Management|
|**Object DB**| No SQL database to store Favorites & Downloads|
|**XML2JSON**| Convert XML to JSON|
|**HTTP**| Network calls|
|**DIO**| Download files|
|**DIO**| Network calls and File Download|
## 🤓 Author(s)

BIN
assets/images/empty.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

View File

@@ -261,7 +261,7 @@ class Details extends StatelessWidget {
SizedBox(height: 30,),
Text(
"Related Books",
"More from Author",
style: TextStyle(
color: Theme.of(context).accentColor,
fontSize: 20,

View File

@@ -36,10 +36,31 @@ class _DownloadsState extends State<Downloads> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text("Downloads"),
// elevation: 4,
),
body: ListView.separated(
body: dls.isEmpty
? Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.asset(
"assets/images/empty.png",
height: 300,
width: 300,
),
Text(
"Nothing is here",
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
],
),
)
: ListView.separated(
padding: EdgeInsets.symmetric(horizontal: 15),
shrinkWrap: true,
itemCount: dls.length,

View File

@@ -16,7 +16,28 @@ class Favorites extends StatelessWidget {
"Favorites",
),
),
body: GridView.builder(
body: favoritesProvider.posts.isEmpty
? Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.asset(
"assets/images/empty.png",
height: 300,
width: 300,
),
Text(
"Nothing is here",
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
],
),
)
: GridView.builder(
padding: EdgeInsets.fromLTRB(10, 20, 10, 0),
shrinkWrap: true,
itemCount: favoritesProvider.posts.length,

View File

@@ -1,6 +1,6 @@
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter_ebook_app/podo/category.dart';
import 'package:http/http.dart' as http;
import 'package:xml2json/xml2json.dart';
class Api {
@@ -27,12 +27,14 @@ class Api {
static String horror =
"https://catalog.feedbooks.com/publicdomain/browse/en/top.atom?cat=FBFIC015000";
static Future<CategoryFeed> getCategory(String url) async {
var res = await http.get(url);
static Future getCategory(String url) async {
Dio dio = Dio();
var res = await dio.get(url);
CategoryFeed category;
if(res.statusCode == 200){
Xml2Json xml2json = new Xml2Json();
xml2json.parse(res.body);
xml2json.parse(res.data.toString());
var json = jsonDecode(xml2json.toGData());
category = CategoryFeed.fromJson(json);
}else{

View File

@@ -185,7 +185,7 @@ packages:
source: hosted
version: "0.14.0+3"
http:
dependency: "direct main"
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"

View File

@@ -25,7 +25,6 @@ dependencies:
page_transition: ^1.1.5
flutter_icons: ^1.0.0+1
flutter_html: ^0.11.0
http: ^0.12.0+3
xml2json: ^4.1.1
fluttertoast: ^3.1.3
esys_flutter_share: ^1.0.2