Skip to content

Commit

Permalink
Added Image Caching
Browse files Browse the repository at this point in the history
Fixed Overscroll Color
  • Loading branch information
ryanhossain9797 committed Nov 3, 2019
1 parent a521d9f commit d638ab6
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 59 deletions.
6 changes: 5 additions & 1 deletion lib/components/pc_component_widget.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:pc_build_assistant/models/pc_component.dart';
Expand All @@ -12,6 +13,9 @@ class PCComponentWidget extends StatelessWidget {
: super(key: key);
@override
Widget build(BuildContext context) {
CachedNetworkImageProvider imgC = CachedNetworkImageProvider(
component.imgurl,
);
NetworkImage img = NetworkImage(component.imgurl);
img.evict();
return Container(
Expand All @@ -37,7 +41,7 @@ class PCComponentWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Image(
image: img,
image: imgC,
width: 100,
height: 100,
),
Expand Down
109 changes: 53 additions & 56 deletions lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,24 @@ class _HomeScreenState extends State<HomeScreen> {
body: Stack(
alignment: AlignmentDirectional.bottomCenter,
children: <Widget>[
PageView(
onPageChanged: (index) {
setState(() {
_index = index;
});
},
controller: _pageController,
pageSnapping: true,
children: <Widget>[
_components.length > 0
? RefreshIndicator(
color: kLoginButtonColor,
onRefresh: () async {
getData();
},
child: Theme(
data: Theme.of(context)
.copyWith(accentColor: kLoginButtonColor),
Theme(
data: Theme.of(context).copyWith(accentColor: kLoginButtonColor),
child: PageView(
onPageChanged: (index) {
setState(() {
_index = index;
});
},
controller: _pageController,
pageSnapping: true,
children: <Widget>[
_components.length > 0
? RefreshIndicator(
color: kLoginButtonColor,
onRefresh: () async {
getData();
},
child: ListView.builder(
addAutomaticKeepAlives: true,
key: UniqueKey(),
itemCount: _components.length,
itemBuilder: (context, index) {
if (index == 0) {
Expand Down Expand Up @@ -207,45 +204,45 @@ class _HomeScreenState extends State<HomeScreen> {
);
},
),
),
)
: Center(
child: TyperAnimatedTextKit(
text: ["Loading"],
duration: Duration(milliseconds: 600),
textStyle: loadingAnimationStyle,
),
),
_components.length > 0
? RefreshIndicator(
color: kLoginButtonColor,
onRefresh: () async {
getData();
},
child: Theme(
data: Theme.of(context)
.copyWith(accentColor: kLoginButtonColor),
child: ListView.builder(
itemCount: _components.length,
itemBuilder: (context, index) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 10),
child: PCComponentWidget(
component: _components[index],
),
);
},
)
: Center(
child: TyperAnimatedTextKit(
text: ["Loading"],
duration: Duration(milliseconds: 600),
textStyle: loadingAnimationStyle,
),
),
)
: Center(
child: TyperAnimatedTextKit(
text: ["Loading"],
duration: Duration(milliseconds: 600),
textStyle: loadingAnimationStyle,
_components.length > 0
? RefreshIndicator(
color: kLoginButtonColor,
onRefresh: () async {
getData();
},
child: Theme(
data: Theme.of(context)
.copyWith(accentColor: kLoginButtonColor),
child: ListView.builder(
itemCount: _components.length,
itemBuilder: (context, index) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 10),
child: PCComponentWidget(
component: _components[index],
),
);
},
),
),
)
: Center(
child: TyperAnimatedTextKit(
text: ["Loading"],
duration: Duration(milliseconds: 600),
textStyle: loadingAnimationStyle,
),
),
),
],
],
),
),

//---------------------------------------------BOTTOM NAVBAR---------------------------------------------
Expand Down
67 changes: 65 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
cached_network_image:
dependency: "direct main"
description:
name: cached_network_image
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0-rc"
charcode:
dependency: transitive
description:
Expand Down Expand Up @@ -104,6 +111,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.1"
flutter_cache_manager:
dependency: "direct main"
description:
name: flutter_cache_manager
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -123,6 +137,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.7"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+2"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
image:
dependency: transitive
description:
Expand Down Expand Up @@ -158,6 +186,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.0"
pedantic:
dependency: transitive
description:
Expand All @@ -172,6 +207,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
quiver:
dependency: transitive
description:
Expand All @@ -198,6 +240,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
sqflite:
dependency: transitive
description:
name: sqflite
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.7+2"
stack_trace:
dependency: transitive
description:
Expand All @@ -219,6 +268,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
synchronized:
dependency: transitive
description:
name: synchronized
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0+1"
term_glyph:
dependency: transitive
description:
Expand All @@ -240,6 +296,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
uuid:
dependency: transitive
description:
name: uuid
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
vector_math:
dependency: transitive
description:
Expand All @@ -255,5 +318,5 @@ packages:
source: hosted
version: "3.5.0"
sdks:
dart: ">=2.4.0 <3.0.0"
flutter: ">=1.5.0 <2.0.0"
dart: ">=2.5.0 <3.0.0"
flutter: ">=1.10.15-pre.148 <2.0.0"
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ dependencies:
simple_gravatar: ^1.0.5
font_awesome_flutter: ^8.5.0
cloud_firestore: ^0.12.9+5
cached_network_image: ^2.0.0-rc
flutter_cache_manager: ^1.1.3

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand Down

0 comments on commit d638ab6

Please sign in to comment.