diff --git a/.github/workflows/deploy_playground_netlify.yml b/.github/workflows/deploy_playground_netlify.yml index 6a6d546ea..6fe593c91 100644 --- a/.github/workflows/deploy_playground_netlify.yml +++ b/.github/workflows/deploy_playground_netlify.yml @@ -15,7 +15,7 @@ name: Deploy_Playground_Netlify on: push: - branches: [none] + branches: [master] paths-ignore: - "**.md" jobs: diff --git a/example/lib/example5_themes_playground/utils/generate_theme_dart_code.dart b/example/lib/example5_themes_playground/utils/generate_theme_dart_code.dart index f4627d479..eb9bbb6f5 100644 --- a/example/lib/example5_themes_playground/utils/generate_theme_dart_code.dart +++ b/example/lib/example5_themes_playground/utils/generate_theme_dart_code.dart @@ -2367,11 +2367,11 @@ String generateThemeDartCode(ThemeController controller) { '/// Use in [MaterialApp] like this:\n' '///\n' '/// MaterialApp(\n' - '/// theme: AppTheme.light,\n' - '/// darkTheme: AppTheme.dark,\n' - '/// :\n' + '/// theme: AppTheme.light,\n' + '/// darkTheme: AppTheme.dark,\n' + '/// :\n' '/// );\n' - 'sealed class AppTheme {\n' + 'abstract final class AppTheme {\n' ' // The defined light theme.\n' ' static ThemeData light = FlexThemeData.light(\n' '$lightScheme' diff --git a/example/lib/example_copy_paste_from_playground/app_theme.dart b/example/lib/example_copy_paste_from_playground/app_theme.dart index 4197b5e60..a05491991 100644 --- a/example/lib/example_copy_paste_from_playground/app_theme.dart +++ b/example/lib/example_copy_paste_from_playground/app_theme.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; /// Use same major flex_color_scheme package version. If you use a /// lower minor version, some properties may not be supported. /// In that case, remove them after copying this theme to your -/// app or upgrade package to version 8.0.0-dev.1. +/// app or upgrade package to version 8.0.2. /// /// Use in [MaterialApp] like this: /// @@ -17,7 +17,7 @@ import 'package:flutter/material.dart'; /// darkTheme: AppTheme.dark, /// : /// ); -sealed class AppTheme { +abstract final class AppTheme { // The defined light theme. static ThemeData light = FlexThemeData.light( scheme: FlexScheme.sakura, diff --git a/example/lib/shared/const/app.dart b/example/lib/shared/const/app.dart index ccdd3e930..ba94e29c4 100644 --- a/example/lib/shared/const/app.dart +++ b/example/lib/shared/const/app.dart @@ -47,7 +47,7 @@ sealed class App { static const String versionMajor = '8'; static const String versionMinor = '0'; static const String versionPatch = '2'; - static const String versionBuild = '01'; + static const String versionBuild = '02'; static const String versionFull = '$versionMajor.$versionMinor.$versionPatch' '\nBuild-$versionBuild'; static const String version = '$versionMajor.$versionMinor.$versionPatch'; @@ -57,10 +57,9 @@ sealed class App { static const String author = 'Mike Rydstrom'; static const String license = 'BSD 3-Clause License'; static const String icon = 'assets/images/app_icon.png'; + static const String playgroundURL = 'https://playground.flexcolorscheme.com/'; // static const String playgroundURL = - // 'https://playground.flexcolorscheme.com/'; - static const String playgroundURL = - 'https://rydmike.com/flexcolorscheme/themesplayground-latest/'; + // 'https://rydmike.com/flexcolorscheme/themesplayground-latest/'; static final Uri packageUri = Uri( scheme: 'https', diff --git a/example/lib/shared/services/theme_service_hive.dart b/example/lib/shared/services/theme_service_hive.dart index e0178ff75..a2d2cdc50 100644 --- a/example/lib/shared/services/theme_service_hive.dart +++ b/example/lib/shared/services/theme_service_hive.dart @@ -1,7 +1,9 @@ import 'package:flutter/foundation.dart'; import 'package:hive_ce/hive.dart'; +import '../const/app.dart'; import '../utils/app_data_dir/app_data_dir.dart'; +import '../utils/same_types.dart'; import 'theme_service.dart'; import 'theme_service_hive_adapters.dart'; @@ -105,14 +107,32 @@ class ThemeServiceHive implements ThemeService { @override Future load(String key, T defaultValue) async { try { - final dynamic value = _hiveBox.get(key, defaultValue: defaultValue); + final dynamic value = await _hiveBox.get(key, defaultValue: defaultValue); if (_debug) { debugPrint('Hive LOAD _______________'); - debugPrint(' Type expected: $key as ${defaultValue.runtimeType}'); - debugPrint(' Type loaded : $key as ${value.runtimeType}'); - debugPrint(' Value loaded : $value'); + debugPrint(' Store key : $key'); + debugPrint(' Type expected : $T'); + debugPrint(' Stored value : $value'); + debugPrint(' Stored type : ${value.runtimeType}'); + debugPrint(' Default value : $defaultValue'); + debugPrint(' Default type : ${defaultValue.runtimeType}'); + } + // Add workaround for Hive WASM returning double instead of int, when + // values saved to IndexedDb were int. + // See issue: https://github.com/IO-Design-Team/hive_ce/issues/46 + if (App.isRunningWithWasm && + value != null && + (value is double) && + (sameTypes() || sameTypes())) { + final T loaded = value.round() as T; + if (_debug) { + debugPrint(' ** WASM Issue : Expected int but got double, ' + 'returning as int: $loaded'); + } + return loaded; + } else { + return value as T; } - return value as T; } catch (e) { debugPrint('Hive load (get) ERROR'); debugPrint(' Error message ...... : $e'); diff --git a/example/pubspec.lock b/example/pubspec.lock index 8318286b3..5c53245ec 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -210,11 +210,10 @@ packages: hive_ce: dependency: "direct main" description: - path: hive - ref: main - resolved-ref: f5d367b6c6b6a8a4bc3b23252e84353ab781197a - url: "https://github.com/rydmike/hive_ce.git" - source: git + name: hive_ce + sha256: "2d66fa89a3e33e6d95edcf6c75409cf8f6442ab46229c9baf423af479f532e99" + url: "https://pub.dev" + source: hosted version: "2.8.0+2" http: dependency: transitive diff --git a/example/pubspec.yaml b/example/pubspec.yaml index dbd93c5a1..e58076d98 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -68,13 +68,13 @@ dependencies: # hive: ^2.2.3 # Original Hive package # This is a community fork that supports WASM-GC, by using package:web and # dart:js_interop. - hive_ce: # ^2.8.0 + hive_ce: ^2.8.0 #path: ../../hive_ce/hive # Temporarily used from a fixed fork until the official package is updated. - git: - url: https://github.com/rydmike/hive_ce.git - ref: main - path: hive/ + #git: + # url: https://github.com/rydmike/hive_ce.git + # ref: main + # path: hive/ # Internationalization package, by Google dart.dev. # Used only for date time string formatting in example 5.