From 03eabac1e939cc580ac4efeee2f0ffffff58508b Mon Sep 17 00:00:00 2001 From: guidezpl <6655696+guidezpl@users.noreply.github.com> Date: Thu, 9 Dec 2021 08:51:13 +0100 Subject: [PATCH] add back shared_preferences --- ios/Podfile.lock | 28 +++++---- ios/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- lib/pages/demo.dart | 11 +++- lib/studies/crane/model/data.dart | 2 - macos/Flutter/GeneratedPluginRegistrant.swift | 2 + macos/Podfile.lock | 6 ++ pubspec.lock | 58 ++++++++++++++++++- pubspec.yaml | 1 + test_goldens/flutter_test_config.dart | 3 +- 10 files changed, 96 insertions(+), 19 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index d15ab47062..b81448f33c 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -2,33 +2,39 @@ PODS: - Flutter (1.0.0) - package_info_plus (0.4.5): - Flutter - - path_provider (0.0.1): + - path_provider_ios (0.0.1): - Flutter - - url_launcher (0.0.1): + - shared_preferences_ios (0.0.1): + - Flutter + - url_launcher_ios (0.0.1): - Flutter DEPENDENCIES: - Flutter (from `Flutter`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - - path_provider (from `.symlinks/plugins/path_provider/ios`) - - url_launcher (from `.symlinks/plugins/url_launcher/ios`) + - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`) + - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`) + - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) EXTERNAL SOURCES: Flutter: :path: Flutter package_info_plus: :path: ".symlinks/plugins/package_info_plus/ios" - path_provider: - :path: ".symlinks/plugins/path_provider/ios" - url_launcher: - :path: ".symlinks/plugins/url_launcher/ios" + path_provider_ios: + :path: ".symlinks/plugins/path_provider_ios/ios" + shared_preferences_ios: + :path: ".symlinks/plugins/shared_preferences_ios/ios" + url_launcher_ios: + :path: ".symlinks/plugins/url_launcher_ios/ios" SPEC CHECKSUMS: Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e - path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c - url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef + path_provider_ios: 7d7ce634493af4477d156294792024ec3485acd5 + shared_preferences_ios: aef470a42dc4675a1cdd50e3158b42e3d1232b32 + url_launcher_ios: 02f1989d4e14e998335b02b67a7590fa34f971af PODFILE CHECKSUM: a75497545d4391e2d394c3668e20cfb1c2bbd4aa -COCOAPODS: 1.10.1 +COCOAPODS: 1.11.2 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 433f3bbeef..65bc0cc8cd 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -155,7 +155,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140cfdb..3db53b6e1f 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ vsync: this, duration: const Duration(milliseconds: 300), ); - // TODO(rami-a): Add back shared_preferences check once migrated to NNBD. - _demoViewedCount = 10; + SharedPreferences.getInstance().then((preferences) { + setState(() { + _demoViewedCount = preferences.getInt(_demoViewedCountKey) ?? 0; + preferences.setInt(_demoViewedCountKey, _demoViewedCount + 1); + }); + }); } @override diff --git a/lib/studies/crane/model/data.dart b/lib/studies/crane/model/data.dart index 3d167ab7d1..d6a874212f 100644 --- a/lib/studies/crane/model/data.dart +++ b/lib/studies/crane/model/data.dart @@ -6,8 +6,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; import 'package:gallery/studies/crane/model/destination.dart'; -// TODO: localize durations - List getFlyDestinations(BuildContext context) => [ FlyDestination( diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index c7621f8564..e63034df6c 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,10 +7,12 @@ import Foundation import package_info_plus_macos import path_provider_macos +import shared_preferences_macos import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 2467eb444a..ac387df1c0 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -4,6 +4,8 @@ PODS: - FlutterMacOS - path_provider_macos (0.0.1): - FlutterMacOS + - shared_preferences_macos (0.0.1): + - FlutterMacOS - url_launcher_macos (0.0.1): - FlutterMacOS @@ -11,6 +13,7 @@ DEPENDENCIES: - FlutterMacOS (from `Flutter/ephemeral`) - package_info_plus_macos (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus_macos/macos`) - path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`) + - shared_preferences_macos (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) EXTERNAL SOURCES: @@ -20,6 +23,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/package_info_plus_macos/macos path_provider_macos: :path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos + shared_preferences_macos: + :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos @@ -27,6 +32,7 @@ SPEC CHECKSUMS: FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 package_info_plus_macos: f010621b07802a241d96d01876d6705f15e77c1c path_provider_macos: 160cab0d5461f0c0e02995469a98f24bdb9a3f1f + shared_preferences_macos: 480ce071d0666e37cef23fe6c702293a3d21799e url_launcher_macos: 45af3d61de06997666568a7149c1be98b41c95d4 PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c diff --git a/pubspec.lock b/pubspec.lock index 3d4f384038..23235f315c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -443,7 +443,7 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.2" + version: "3.1.0" plugin_platform_interface: dependency: transitive description: @@ -493,6 +493,62 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0-nullsafety.0" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" + shared_preferences_ios: + dependency: transitive + description: + name: shared_preferences_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.8" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + shared_preferences_macos: + dependency: transitive + description: + name: shared_preferences_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" shelf: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index f2e8e2e73c..c44ac5e561 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,6 +29,7 @@ dependencies: shrine_images: ^2.0.1 url_launcher: ^6.0.3 vector_math: ^2.1.0 + shared_preferences: ^2.0.9 dev_dependencies: flutter_test: diff --git a/test_goldens/flutter_test_config.dart b/test_goldens/flutter_test_config.dart index 0baf9016ed..36634ff3e9 100644 --- a/test_goldens/flutter_test_config.dart +++ b/test_goldens/flutter_test_config.dart @@ -6,6 +6,7 @@ import 'dart:async'; import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'testing/font_loader.dart'; @@ -23,7 +24,7 @@ Future testExecutable(FutureOr Function() testMain) async { // Disabling the warning because @visibleForTesting doesn't take the testing // framework into account. // ignore: invalid_use_of_visible_for_testing_member - // TODO(rami-a): Add back shared_preferences mocking once migrated to NNBD. + SharedPreferences.setMockInitialValues({}); await loadFonts(); await testMain(); }