Make RainRadar reloadable by user
This commit is contained in:
+32
-24
@@ -28,7 +28,6 @@ class _RainRadarState extends State<RainRadar>
|
|||||||
controllerValue = controller.value;
|
controllerValue = controller.value;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
controller.stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -46,7 +45,6 @@ class _RainRadarState extends State<RainRadar>
|
|||||||
_gifBytes = gif.readAsBytesSync();
|
_gifBytes = gif.readAsBytesSync();
|
||||||
_gifLoaded = true;
|
_gifLoaded = true;
|
||||||
});
|
});
|
||||||
// controller.animateTo(24, duration: const Duration(seconds: 15));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,17 +52,16 @@ class _RainRadarState extends State<RainRadar>
|
|||||||
return Column(children: [
|
return Column(children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
child: _gifLoaded
|
child: VisibilityDetector(
|
||||||
? VisibilityDetector(
|
key: const Key('gif-key'),
|
||||||
key: const Key('gif-key'),
|
onVisibilityChanged: (visibilityInfo) {
|
||||||
onVisibilityChanged: (visibilityInfo) {
|
if (visibilityInfo.visibleFraction > 0) {
|
||||||
controller.animateTo(24,
|
controller.animateTo(24, duration: const Duration(seconds: 15));
|
||||||
duration: const Duration(seconds: 15));
|
}
|
||||||
},
|
},
|
||||||
child: GifImage(
|
child:
|
||||||
controller: controller, image: MemoryImage(_gifBytes)),
|
GifImage(controller: controller, image: MemoryImage(_gifBytes)),
|
||||||
)
|
)),
|
||||||
: const CircularProgressIndicator()),
|
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -97,16 +94,27 @@ class _RainRadarState extends State<RainRadar>
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Rain Radar'),
|
title: const Text('Rain Radar'),
|
||||||
),
|
),
|
||||||
body: _gifLoaded
|
body: RefreshIndicator(
|
||||||
? _showGif()
|
onRefresh: (() {
|
||||||
: Column(
|
return Future(() {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
setState(() {
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
_gifLoaded = false;
|
||||||
children: const [
|
});
|
||||||
SizedBox(
|
loadGif();
|
||||||
height: 50,
|
});
|
||||||
),
|
}),
|
||||||
Center(child: CircularProgressIndicator())
|
child: SingleChildScrollView(
|
||||||
]));
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
child: _gifLoaded
|
||||||
|
? _showGif()
|
||||||
|
: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: const [
|
||||||
|
SizedBox(
|
||||||
|
height: 50,
|
||||||
|
),
|
||||||
|
Center(child: CircularProgressIndicator())
|
||||||
|
]))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user