Skip to content

Commit

Permalink
fix: improve image load speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Anxcye committed May 10, 2024
1 parent 17c77f7 commit e5906f5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/page/book_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class _BookDetailState extends State<BookDetail> {
void initState() {
super.initState();
rating = widget.book.rating;
coverImage = Image.memory(File(widget.book.coverFullPath).readAsBytesSync());
coverImage = Image.file(File(widget.book.coverFullPath));
}

@override
Expand Down Expand Up @@ -213,7 +213,7 @@ class _BookDetailState extends State<BookDetail> {
widget.book.coverPath = newPath;

setState(() {
coverImage = Image.memory(File(image.path).readAsBytesSync());
coverImage = Image.file(File(image.path));
updateBook(widget.book);
widget.onRefresh();
});
Expand Down
4 changes: 2 additions & 2 deletions lib/page/book_notes_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ Widget bookInfo(BuildContext context, Book book, int numberOfNotes) {
ClipRRect bookCover(Book book) {
return ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.memory(
child: Image.file(
File(
book.coverFullPath,
).readAsBytesSync(),
),
height: 180,
width: 120,
fit: BoxFit.cover,
Expand Down
4 changes: 2 additions & 2 deletions lib/page/home_page/notes_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ class _NotesPageState extends State<NotesPage> {
// Expanded(child: SizedBox()),
ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.memory(
child: Image.file(
File(
snapshot.data!.coverFullPath,
).readAsBytesSync(),
),
height: 130,
width: 90,
fit: BoxFit.cover,
Expand Down
4 changes: 2 additions & 2 deletions lib/page/home_page/statistics_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ class BookStatisticItem extends StatelessWidget {
children: [
ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.memory(
child: Image.file(
File(
snapshot.data!.coverFullPath,
).readAsBytesSync(),
),
height: 130,
width: 90,
fit: BoxFit.cover,
Expand Down
2 changes: 2 additions & 0 deletions lib/utils/webdav/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class AnxWebdav {
syncDatabase(direction).then((value) {
AnxToast.show(context.webdavSyncingFiles);
syncFiles().then((value) {
imageCache.clear();
imageCache.clearLiveImages();
// refresh book list
const BookshelfPage().refreshBookList();
AnxToast.show(context.webdavSyncComplete);
Expand Down
4 changes: 1 addition & 3 deletions lib/widgets/book_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ class BookItem extends StatelessWidget {
color: Colors.grey,
),
image: DecorationImage(
image:
Image.memory(File(book.coverFullPath).readAsBytesSync())
.image,
image: Image.file(File(book.coverFullPath)).image,
fit: BoxFit.cover,
),
boxShadow: [
Expand Down

0 comments on commit e5906f5

Please sign in to comment.