mirror of
https://github.com/JideGuru/FlutterEbookApp.git
synced 2026-03-13 10:00:29 +08:00
Removed HTTP and used DIO for network calls
This commit is contained in:
@@ -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
BIN
assets/images/empty.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 71 KiB |
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user