improve gif loading even further
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:typed_data';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gifimage/flutter_gifimage.dart';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
import 'package:visibility_detector/visibility_detector.dart';
|
||||
|
||||
class RainRadar extends StatefulWidget {
|
||||
const RainRadar({Key? key}) : super(key: key);
|
||||
@@ -45,7 +46,7 @@ class _RainRadarState extends State<RainRadar>
|
||||
_gifBytes = gif.readAsBytesSync();
|
||||
_gifLoaded = true;
|
||||
});
|
||||
controller.animateTo(24, duration: const Duration(seconds: 15));
|
||||
// controller.animateTo(24, duration: const Duration(seconds: 15));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,7 +55,15 @@ class _RainRadarState extends State<RainRadar>
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: _gifLoaded
|
||||
? GifImage(controller: controller, image: MemoryImage(_gifBytes))
|
||||
? VisibilityDetector(
|
||||
key: const Key('gif-key'),
|
||||
onVisibilityChanged: (visibilityInfo) {
|
||||
controller.animateTo(24,
|
||||
duration: const Duration(seconds: 15));
|
||||
},
|
||||
child: GifImage(
|
||||
controller: controller, image: MemoryImage(_gifBytes)),
|
||||
)
|
||||
: const CircularProgressIndicator()),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
ElevatedButton(
|
||||
|
||||
@@ -406,6 +406,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
visibility_detector:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: visibility_detector
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.3"
|
||||
weather_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
@@ -40,6 +40,7 @@ dependencies:
|
||||
flutter_gifimage:
|
||||
path: ../flutter_gifimage-1.0.1
|
||||
flutter_cache_manager: ^3.3.0
|
||||
visibility_detector: ^0.3.3
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user