From 682bb99812dda71ded4fd15b0c44773f31016458 Mon Sep 17 00:00:00 2001 From: Niels Gorter Date: Fri, 7 Oct 2022 15:59:02 +0200 Subject: [PATCH] added shared prefs variant in example --- example/lib/main.dart | 5 +- example/pubspec.lock | 142 +++++++++++++++++++++++++++++++++- example/pubspec.yaml | 4 + lib/flutter_introduction.dart | 7 +- 4 files changed, 153 insertions(+), 5 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 3ea6b6c..12a169a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_introduction/flutter_introduction.dart'; +import 'package:flutter_introduction_shared_preferences/flutter_introduction_shared_preferences.dart'; void main() { runApp(const MyApp()); @@ -28,7 +29,8 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - IntroductionService service = IntroductionService(); + IntroductionService service = + IntroductionService(SharedPreferencesIntroductionDataProvider()); @override Widget build(BuildContext context) { @@ -79,6 +81,7 @@ class _MyHomePageState extends State { ), ); }, + child: const Home(), ), ); } diff --git a/example/pubspec.lock b/example/pubspec.lock index 09e4484..04bc2fe 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -127,6 +127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" file: dependency: transitive description: @@ -180,6 +187,15 @@ packages: url: "https://github.com/Iconica-Development/flutter_introduction_service.git" source: git version: "0.0.1" + flutter_introduction_shared_preferences: + dependency: "direct main" + description: + path: "." + ref: master + resolved-ref: "2fa4deadeb60ff5bcde2c1f3e02791221d0dd07c" + url: "https://github.com/Iconica-Development/flutter_introduction_shared_preferences.git" + source: git + version: "0.0.1" flutter_introduction_widget: dependency: transitive description: @@ -201,6 +217,11 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" glob: dependency: transitive description: @@ -229,6 +250,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.0.1" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.4" lints: dependency: transitive description: @@ -285,6 +313,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.2" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.7" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" pub_semver: dependency: transitive description: @@ -299,6 +369,62 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.7.33" + shared_preferences: + dependency: transitive + description: + name: shared_preferences + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.15" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.13" + shared_preferences_ios: + dependency: transitive + description: + name: shared_preferences_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + shared_preferences_macos: + dependency: transitive + description: + name: shared_preferences_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" sky_engine: dependency: transitive description: flutter @@ -374,6 +500,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.1" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0+2" yaml: dependency: transitive description: @@ -383,4 +523,4 @@ packages: version: "3.1.1" sdks: dart: ">=2.18.0 <3.0.0" - flutter: ">=1.17.0" + flutter: ">=3.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b83a6d6..7e4e179 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -38,6 +38,10 @@ dependencies: cupertino_icons: ^1.0.2 flutter_introduction: path: ../ + flutter_introduction_shared_preferences: + git: + url: https://github.com/Iconica-Development/flutter_introduction_shared_preferences.git + ref: master dev_dependencies: flutter_test: diff --git a/lib/flutter_introduction.dart b/lib/flutter_introduction.dart index 4915a6d..609e530 100644 --- a/lib/flutter_introduction.dart +++ b/lib/flutter_introduction.dart @@ -11,6 +11,7 @@ class Introduction extends StatefulWidget { const Introduction({ required this.navigateTo, required this.options, + required this.child, this.physics, this.service, super.key, @@ -20,6 +21,7 @@ class Introduction extends StatefulWidget { final IntroductionService? service; final IntroductionOptions options; final ScrollPhysics? physics; + final Widget child; @override State createState() => _IntroductionState(); @@ -51,14 +53,13 @@ class _IntroductionState extends State { widget.navigateTo(); }, physics: widget.physics, - onSkip: () { + onSkip: () async { _service.onComplete(); widget.navigateTo(); }, ); } else { - widget.navigateTo(); - return Container(); + return widget.child; } }, );