我正在嘗試introduction_screen 2.1.0來顯示介紹螢屏。我匯入它并宣告匯入:
import 'package:introduction_screen/introduction_screen.dart';
但是當我呼叫IntroductionScreen() 時,發生了錯誤。
_AssertionError ('package:introduction_screen/src/introduction_screen.dart': Failed assertion: line 209 pos 16: '(showNextButton && next != null) || !showNextButton': is not true.)
我參考了一些例子并寫了這個簡單的代碼:
class Intro extends StatefulWidget {
const Intro({Key? key}) : super(key: key);
@override
_Intro createState() => _Intro();
}
class _Intro extends State<Intro> {
List<PageViewModel> getPages() {
return [
PageViewModel(
image: null,
title: "Live Demo page 1",
body: "Welcome to Proto Coders Point",
footer: Text("Footer Text here "),
decoration: const PageDecoration(
pageColor: Colors.blue,
)),
// .................
];
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Example"),
),
body: SafeArea(
child: IntroductionScreen( // ERROR!!
globalBackgroundColor: Colors.white,
pages: getPages(),
showNextButton: true,
showSkipButton: true,
skip: Text("Skip"),
done: Text("Got it "),
onDone: () {},
)));
}
}
正如我之前所說,IntroductionScreen() 是一個問題。
我正確匯入了 pub,看起來我的環境還可以。
[√] Flutter (Channel beta, 2.6.0-5.2.pre, on Microsoft Windows [Version 10.0.22000.258], locale ja-JP)
? Flutter version 2.6.0-5.2.pre at D:\src\flutter_windows_2.5.0-stable\flutter
? Upstream repository https://github.com/flutter/flutter.git
? Framework revision 400608f101 (5 weeks ago), 2021-09-15 15:50:26 -0700
? Engine revision 1d521d89d8
? Dart version 2.15.0 (build 2.15.0-82.2.beta)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
? Android SDK at D:\Android
? Platform android-30, build-tools 29.0.3
? Java binary at: D:\Program Files\Android\Android Studio\jre\bin\java
? Java version OpenJDK Runtime Environment (build 11.0.8 10-b944.6842174)
? All Android licenses accepted.
[√] Chrome - develop for the web
? Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.2)
? Android Studio at D:\Program Files\Android\Android Studio
? Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
? Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
? Java version OpenJDK Runtime Environment (build 11.0.8 10-b944.6842174)
[√] VS Code (version 1.61.2)
? VS Code at C:\Users\yukik\AppData\Local\Programs\Microsoft VS Code
? Flutter extension version 3.27.0
[√] Connected device (3 available)
? Android SDK built for x86 (mobile) ? emulator-5554 ? android-x86 ? Android 10 (API 29) (emulator)
? Chrome (web) ? chrome ? web-javascript ? Google Chrome 95.0.4638.54
? Edge (web) ? edge ? web-javascript ? Microsoft Edge 95.0.1020.30
? No issues found!
uj5u.com熱心網友回復:
從檔案:
定義 Next 按鈕(Widget),通過添加 next: Text('Next') 這個引數是必需的,除非你設定了 showNextButton: false
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/334715.html
