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