chore: switch to cached_network_image

This commit is contained in:
Sorunome 2020-09-07 17:08:01 +02:00
parent fadf8715c3
commit bbca0c2bee
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
9 changed files with 29 additions and 81 deletions

View File

@ -2,7 +2,7 @@ import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/string_color.dart'; import 'package:fluffychat/utils/string_color.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_advanced_networkimage/provider.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'matrix.dart'; import 'matrix.dart';
@ -41,12 +41,7 @@ class Avatar extends StatelessWidget {
onTap: onTap, onTap: onTap,
child: CircleAvatar( child: CircleAvatar(
radius: size / 2, radius: size / 2,
backgroundImage: !noPic backgroundImage: !noPic ? CachedNetworkImageProvider(src) : null,
? AdvancedNetworkImage(
src,
useDiskCache: !kIsWeb,
)
: null,
backgroundColor: noPic backgroundColor: noPic
? name?.lightColor ?? Theme.of(context).secondaryHeaderColor ? name?.lightColor ?? Theme.of(context).secondaryHeaderColor
: Theme.of(context).secondaryHeaderColor, : Theme.of(context).secondaryHeaderColor,

View File

@ -1,7 +1,7 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_advanced_networkimage/provider.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'matrix.dart'; import 'matrix.dart';
@ -48,13 +48,10 @@ class ContentBanner extends StatelessWidget {
opacity: 0.75, opacity: 0.75,
child: !loading child: !loading
? mxContent != null ? mxContent != null
? Image( ? CachedNetworkImage(
imageUrl: src,
height: 300, height: 300,
fit: BoxFit.cover, fit: BoxFit.cover,
image: AdvancedNetworkImage(
src,
useDiskCache: !kIsWeb,
),
) )
: Icon(defaultIcon, size: 300) : Icon(defaultIcon, size: 300)
: Icon(defaultIcon, size: 300), : Icon(defaultIcon, size: 300),

View File

@ -5,8 +5,7 @@ import 'package:fluffychat/views/image_view.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_blurhash/flutter_blurhash.dart'; import 'package:flutter_blurhash/flutter_blurhash.dart';
import 'package:flutter_advanced_networkimage/provider.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter_advanced_networkimage/transition.dart';
class ImageBubble extends StatefulWidget { class ImageBubble extends StatefulWidget {
final Event event; final Event event;
@ -126,16 +125,13 @@ class _ImageBubbleState extends State<ImageBubble> {
fit: widget.fit, fit: widget.fit,
); );
} else if (isUnencrypted) { } else if (isUnencrypted) {
renderWidget = TransitionToImage( renderWidget = CachedNetworkImage(
image: AdvancedNetworkImage( imageUrl: Uri.parse(widget.event.content['url']).getThumbnail(
Uri.parse(widget.event.content['url']).getThumbnail( widget.event.room.client,
widget.event.room.client, width: 800,
width: 800, height: 800,
height: 800, method: ThumbnailMethod.scale),
method: ThumbnailMethod.scale), placeholder: (context, url) => generatePlaceholderWidget(),
useDiskCache: !kIsWeb,
),
loadingWidget: generatePlaceholderWidget(),
fit: widget.fit, fit: widget.fit,
); );
} else { } else {

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter_typeahead/flutter_typeahead.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:flutter_advanced_networkimage/provider.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'avatar.dart'; import 'avatar.dart';
class InputBar extends StatelessWidget { class InputBar extends StatelessWidget {
@ -146,8 +146,8 @@ class InputBar extends StatelessWidget {
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Image( CachedNetworkImage(
image: AdvancedNetworkImage(url, useDiskCache: !kIsWeb), imageUrl: url,
width: size, width: size,
height: size, height: size,
), ),

View File

@ -1,7 +1,6 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_advanced_networkimage/provider.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'matrix.dart'; import 'matrix.dart';
@ -89,13 +88,11 @@ class _Reaction extends StatelessWidget {
content = Row( content = Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Image( CachedNetworkImage(
image: AdvancedNetworkImage( imageUrl: src,
src,
useDiskCache: !kIsWeb,
),
height: fontSize, height: fontSize,
), ),
Container(width: 4),
Text(count.toString(), Text(count.toString(),
style: TextStyle( style: TextStyle(
color: textColor, color: textColor,

View File

@ -2,7 +2,7 @@ import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/image_bubble.dart'; import 'package:fluffychat/components/image_bubble.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_advanced_networkimage/zoomable.dart'; import 'package:photo_view/photo_view.dart';
import '../utils/event_extension.dart'; import '../utils/event_extension.dart';
class ImageView extends StatelessWidget { class ImageView extends StatelessWidget {
@ -41,7 +41,7 @@ class ImageView extends StatelessWidget {
), ),
], ],
), ),
body: ZoomableWidget( body: PhotoView.customChild(
minScale: 1.0, minScale: 1.0,
maxScale: 10.0, maxScale: 10.0,
child: ImageBubble( child: ImageBubble(

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_advanced_networkimage/provider.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
@ -329,11 +329,8 @@ class _EmoteImage extends StatelessWidget {
height: size * devicePixelRatio, height: size * devicePixelRatio,
method: ThumbnailMethod.scale, method: ThumbnailMethod.scale,
); );
return Image( return CachedNetworkImage(
image: AdvancedNetworkImage( imageUrl: url,
url,
useDiskCache: !kIsWeb,
),
fit: BoxFit.contain, fit: BoxFit.contain,
width: size, width: size,
height: size, height: size,

View File

@ -79,7 +79,7 @@ packages:
source: hosted source: hosted
version: "1.1.9+1" version: "1.1.9+1"
cached_network_image: cached_network_image:
dependency: transitive dependency: "direct main"
description: description:
name: cached_network_image name: cached_network_image
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
@ -232,15 +232,6 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_advanced_networkimage:
dependency: "direct main"
description:
path: "."
ref: master
resolved-ref: f0f599fb89c494d9158fb6f13d4870582f8ecfcb
url: "https://github.com/mchome/flutter_advanced_networkimage"
source: git
version: "0.8.0"
flutter_blurhash: flutter_blurhash:
dependency: "direct main" dependency: "direct main"
description: description:
@ -330,13 +321,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
flutter_svg:
dependency: transitive
description:
name: flutter_svg
url: "https://pub.dartlang.org"
source: hosted
version: "0.18.0"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -594,20 +578,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0-nullsafety" version: "1.8.0-nullsafety"
path_drawing:
dependency: transitive
description:
name: path_drawing
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.1"
path_parsing:
dependency: transitive
description:
name: path_parsing
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
path_provider: path_provider:
dependency: "direct main" dependency: "direct main"
description: description:
@ -656,7 +626,7 @@ packages:
name: photo_view name: photo_view
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.9.2" version: "0.10.2"
platform: platform:
dependency: transitive dependency: transitive
description: description:

View File

@ -34,10 +34,7 @@ dependencies:
memoryfilepicker: ^0.1.3 memoryfilepicker: ^0.1.3
url_launcher: ^5.4.1 url_launcher: ^5.4.1
url_launcher_web: ^0.1.0 url_launcher_web: ^0.1.0
flutter_advanced_networkimage: cached_network_image: ^2.3.1
git:
url: https://github.com/mchome/flutter_advanced_networkimage
ref: master
firebase_messaging: ^6.0.13 firebase_messaging: ^6.0.13
flutter_local_notifications: ^1.4.3 flutter_local_notifications: ^1.4.3
matrix_link_text: ^0.1.5 matrix_link_text: ^0.1.5
@ -49,7 +46,7 @@ dependencies:
universal_html: ^1.1.12 universal_html: ^1.1.12
receive_sharing_intent: ^1.3.3 receive_sharing_intent: ^1.3.3
flutter_slidable: ^0.5.4 flutter_slidable: ^0.5.4
photo_view: ^0.9.2 photo_view: ^0.10.2
flutter_sound: ^2.1.1 flutter_sound: ^2.1.1
open_file: ^3.0.1 open_file: ^3.0.1
mime_type: ^0.3.0 mime_type: ^0.3.0
@ -71,7 +68,6 @@ dependencies:
ref: master ref: master
flutter_blurhash: ^0.5.0 flutter_blurhash: ^0.5.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter