Flutter 颤振:自动提前滑动,延迟3秒
我正在使用处的软件包作为应用程序的登录屏幕 它当前从第一张幻灯片开始,然后滑动到下一张幻灯片。我已经隐藏了下一个和上一个按钮 我希望它在三秒钟后移到下一张幻灯片,然后移到最后一张,基本上不需要下一个和上一个按钮 我尝试过使用AnimatedSwitcher,但我不知道如何在这个用例中正确地实现它 这是我的机载屏幕代码Flutter 颤振:自动提前滑动,延迟3秒,flutter,dart,flutter-animation,Flutter,Dart,Flutter Animation,我正在使用处的软件包作为应用程序的登录屏幕 它当前从第一张幻灯片开始,然后滑动到下一张幻灯片。我已经隐藏了下一个和上一个按钮 我希望它在三秒钟后移到下一张幻灯片,然后移到最后一张,基本上不需要下一个和上一个按钮 我尝试过使用AnimatedSwitcher,但我不知道如何在这个用例中正确地实现它 这是我的机载屏幕代码 import 'package:flutter/material.dart'; import 'package:intro_slider/intro_slider.dart'; i
import 'package:flutter/material.dart';
import 'package:intro_slider/intro_slider.dart';
import 'package:intro_slider/slide_object.dart';
import 'package:localstorage/localstorage.dart';
import '../../common/config.dart' as config;
import '../../common/constants.dart';
class OnBoardScreen extends StatefulWidget {
final appConfig;
OnBoardScreen(this.appConfig);
@override
_OnBoardScreenState createState() => _OnBoardScreenState();
}
class _OnBoardScreenState extends State<OnBoardScreen> {
final isRequiredLogin = config.kAdvanceConfig['IsRequiredLogin'];
int page = 0;
Future<void> setFirstSeen(bool value) async {
final LocalStorage storage = LocalStorage("fstore");
try {
final ready = await storage.ready;
if (ready) {
await storage.setItem(kLocalKey["isFirstSeen"], value);
}
} catch (err) {
print(err);
}
}
List<Slide> slides = List();
@override
void initState() {
super.initState();
slides.add(
// ignore: unnecessary_new
Slide(
title: "We're bringing Africa to the World,",
styleTitle: const TextStyle(
color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.bold),
description:
"Building Africa’s most respected media brand, across television, mobile, and web.",
pathImage: "assets/images/first-onboarding.png",
widthImage: 480,
heightImage: 400,
foregroundImageFit: BoxFit.contain,
backgroundColor: Colors.black,
),
);
slides.add(
// ignore: unnecessary_new
Slide(
title: "By Telling the True African Story,",
styleTitle: const TextStyle(
color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.bold),
description:
"In our news stories, we bring factual content and real shared experiences to our audience.",
pathImage: "assets/images/fogg-delivery-1.png",
heightImage: 400,
widthImage: 480,
foregroundImageFit: BoxFit.contain,
backgroundColor: Colors.black,
),
);
slides.add(
// ignore: unnecessary_new
Slide(
title: "From an African Perspective.",
styleTitle: const TextStyle(
color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.bold),
description:
"Unlocking the essence, expressions and textures of Africa..",
pathImage: "assets/images/fogg-order-completed.png",
widthImage: 480,
heightImage: 400,
foregroundImageFit: BoxFit.contain,
backgroundColor: Colors.black,
),
);
}
void onDonePress() {
// Do what you want
}
@override
Widget build(BuildContext context) {
return IntroSlider(
isShowDotIndicator: true,
isShowPrevBtn: false,
isShowDoneBtn: true,
isShowNextBtn: false,
colorDot: Colors.white,
colorActiveDot: Colors.blue,
slides: slides,
onSkipPress: () async {
await setFirstSeen(true).whenComplete(() => {
Navigator.pushNamed(context, '/home'),
});
},
onDonePress: () async {
await setFirstSeen(true).whenComplete(() => {
Navigator.pushNamed(context, '/home'),
});
},
);
}
}