Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
add back shared_preferences (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
guidezpl authored Dec 10, 2021
1 parent 55c53ab commit acc51cb
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 19 deletions.
28 changes: 17 additions & 11 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
11 changes: 9 additions & 2 deletions lib/pages/demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import 'package:gallery/pages/splash.dart';
import 'package:gallery/themes/gallery_theme_data.dart';
import 'package:gallery/themes/material_demo_theme_data.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart';

const _demoViewedCountKey = 'demoViewedCountKey';

enum _DemoState {
normal,
options,
Expand Down Expand Up @@ -131,8 +134,12 @@ class _GalleryDemoPageState extends State<GalleryDemoPage>
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
Expand Down
2 changes: 0 additions & 2 deletions lib/studies/crane/model/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<FlyDestination> getFlyDestinations(BuildContext context) =>
<FlyDestination>[
FlyDestination(
Expand Down
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
6 changes: 6 additions & 0 deletions macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ PODS:
- FlutterMacOS
- path_provider_macos (0.0.1):
- FlutterMacOS
- shared_preferences_macos (0.0.1):
- FlutterMacOS
- url_launcher_macos (0.0.1):
- FlutterMacOS

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:
Expand All @@ -20,13 +23,16 @@ 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

SPEC CHECKSUMS:
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
package_info_plus_macos: f010621b07802a241d96d01876d6705f15e77c1c
path_provider_macos: 160cab0d5461f0c0e02995469a98f24bdb9a3f1f
shared_preferences_macos: 480ce071d0666e37cef23fe6c702293a3d21799e
url_launcher_macos: 45af3d61de06997666568a7149c1be98b41c95d4

PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
Expand Down
58 changes: 57 additions & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion test_goldens/flutter_test_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -23,7 +24,7 @@ Future<void> testExecutable(FutureOr<void> 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(<String, String>{});
await loadFonts();
await testMain();
}

0 comments on commit acc51cb

Please sign in to comment.