controls of rain radar and slider update
This commit is contained in:
+29
-13
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
// ignore: import_of_legacy_library_into_null_safe
|
||||
import 'package:flutter_gifimage/flutter_gifimage.dart';
|
||||
|
||||
class RainRadar extends StatefulWidget {
|
||||
@@ -12,33 +11,50 @@ class RainRadar extends StatefulWidget {
|
||||
class _RainRadarState extends State<RainRadar>
|
||||
with SingleTickerProviderStateMixin<RainRadar> {
|
||||
late GifController controller;
|
||||
double controllerValue = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
controller = GifController(vsync: this);
|
||||
controller.addListener(() {
|
||||
setState(() {
|
||||
controllerValue = controller.value;
|
||||
});
|
||||
});
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
controller.repeat(min: 0, max: 24, period: const Duration(seconds: 10));
|
||||
controller.animateTo(24, duration: const Duration(seconds: 10));
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
controller.stop();
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Rain Radar'),
|
||||
),
|
||||
body: Column(children: [
|
||||
GifImage(
|
||||
controller: controller,
|
||||
image: const NetworkImage(
|
||||
'https://www.dwd.de/DWD/wetter/radar/radarvhs.gif')),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
controller.stop();
|
||||
},
|
||||
child: const Text("Stop")),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: GifImage(
|
||||
controller: controller,
|
||||
image: const NetworkImage(
|
||||
'https://www.dwd.de/DWD/wetter/radar/radarvhs.gif'))),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
int duration = ((10 / 24) * (24 - controller.value)).round();
|
||||
controller.animateTo(24,
|
||||
duration: Duration(seconds: duration));
|
||||
},
|
||||
child: const Icon(Icons.play_arrow)),
|
||||
const SizedBox(width: 10),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
controller.stop();
|
||||
},
|
||||
child: const Icon(Icons.pause)),
|
||||
]),
|
||||
Slider(
|
||||
onChanged: (v) {
|
||||
controller.value = v;
|
||||
@@ -46,7 +62,7 @@ class _RainRadarState extends State<RainRadar>
|
||||
},
|
||||
max: 24,
|
||||
min: 0,
|
||||
value: controller.value,
|
||||
value: controllerValue,
|
||||
)
|
||||
]));
|
||||
}
|
||||
|
||||
+3
-3
@@ -79,9 +79,9 @@ packages:
|
||||
flutter_gifimage:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_gifimage
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
path: "../flutter_gifimage-1.0.1"
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.1"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
|
||||
+3
-4
@@ -3,7 +3,7 @@ description: A new Flutter project.
|
||||
|
||||
# The following line prevents the package from being accidentally published to
|
||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||
|
||||
# The following defines the version and build number for your application.
|
||||
# A version number is three numbers separated by dots, like 1.2.43
|
||||
@@ -30,7 +30,6 @@ dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.2
|
||||
@@ -38,7 +37,8 @@ dependencies:
|
||||
weather_icons: ^3.0.0
|
||||
intl: ^0.17.0
|
||||
shared_preferences: ^2.0.15
|
||||
flutter_gifimage: ^1.0.1
|
||||
flutter_gifimage:
|
||||
path: ../flutter_gifimage-1.0.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
@@ -56,7 +56,6 @@ dev_dependencies:
|
||||
|
||||
# The following section is specific to Flutter packages.
|
||||
flutter:
|
||||
|
||||
# The following line ensures that the Material Icons font is
|
||||
# included with your application, so that you can use the icons in
|
||||
# the material Icons class.
|
||||
|
||||
Reference in New Issue
Block a user