Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Changelog

## 2.1.0
## 2.1.2

- Fix Playx boot initialization inside Sentry's `appRunner` zone.
- Add `appRunner` support to `runPlayx`.
- Deprecate the `app` parameter in `runPlayx`.

## 2.1.0 - 2.1.1

### Dependency Updates
* `playx_navigation: ^2.0.0`
* `playx_navigation: ^2.1.0`

### Navigation Enhancements (`playx_navigation` 2.0.0)
* **Updated `PlayxNavigationSettings.goRouter`** to accept the new `PlayxPageConfig? config` parameter, enabling global defaults for:
Expand Down
9 changes: 7 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void main() async {
fileName: 'assets/env/keys.env',
),
localeConfigBuilder: () => createLocaleConfig(),
app: const MyApp(),
appRunner: () => runApp(const MyApp()),
//not necessary
// sentryOptions: (options) {
// options.dsn = AppConfig.sentryKey;
Expand All @@ -26,7 +26,12 @@ void main() async {
final goRouter = GoRouter(
routes: [
PlayxRoute(
path: '/', builder: (context, state, isInitialized) => const Home()),
path: '/',
builder: (
context,
state,
) =>
const Home()),
],
);

Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.1.0"
version: "2.1.1"
playx_core:
dependency: transitive
description:
Expand All @@ -712,10 +712,10 @@ packages:
dependency: transitive
description:
name: playx_navigation
sha256: "31f774a4da59e7264d2647094b35f0640b78f65cfd68fa3f82f19e28bbe22776"
sha256: "199939b6928cd739209543dad86f0c7e7489bc63b3a2b94a98593a9d98afd339"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
version: "2.1.0"
playx_network:
dependency: transitive
description:
Expand Down
64 changes: 44 additions & 20 deletions lib/src/playx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ typedef PlayxAppConfigBuilder = PlayXAppConfig Function();
typedef PlayxLocaleConfigBuilder = PlayxLocaleConfig Function();
typedef PlayxThemeConfigBuilder = PlayxThemeConfig Function();
typedef PlayxEnvSettingsBuilder = PlayxEnvSettings Function()?;
typedef PlayxAppRunner = FutureOr<void> Function();

/// The Playx library provides a suite of utilities for app setup, configuration, and management.
///
Expand Down Expand Up @@ -147,7 +148,7 @@ abstract class Playx {

/// Wraps `runApp` to initialize and set up Playx packages before running the app.
///
/// [app]: The root widget of the application.
/// [appRunner]: Runs the application after Playx finishes booting.
/// [appConfigBuilder]: A function that returns the app configuration.
/// [localeConfigBuilder]: A function that returns the locale configuration.
/// [themeConfigBuilder]: A function that returns the theme configuration.
Expand All @@ -157,7 +158,7 @@ abstract class Playx {
/// [envSettingsBuilder]: A function that returns optional environment settings.
/// [sentryOptions]: Optional Sentry configuration for crash reporting.
static Future<void> runPlayx({
required Widget app,
PlayxAppRunner? appRunner,
PlayxAppConfigBuilder? appConfigBuilder,
PlayxLocaleConfigBuilder? localeConfigBuilder,
PlayxThemeConfigBuilder? themeConfigBuilder,
Expand All @@ -169,6 +170,7 @@ abstract class Playx {
FlutterOptionsConfiguration? sentryOptions,
PlayxWebSettings webSettings = const PlayxWebSettings(),
// Deprecated parameters
@Deprecated('Use appRunner instead.') Widget? app,
@Deprecated('Use appConfigBuilder instead.') PlayXAppConfig? appConfig,
@Deprecated('Use localeConfigBuilder instead.')
PlayxLocaleConfig? localeConfig,
Expand Down Expand Up @@ -200,31 +202,53 @@ abstract class Playx {
(envSettingsBuilder == null && envSettings != null),
'Use either envSettingsBuilder or envSettings, not both.',
);

// Boots Playx dependencies.
await boot(
appConfig: appConfig,
themeConfig: themeConfig,
envSettings: envSettings,
localeConfig: localeConfig,
appConfigBuilder: appConfigBuilder,
localeConfigBuilder: localeConfigBuilder,
themeConfigBuilder: themeConfigBuilder,
envSettingsBuilder: envSettingsBuilder,
securePrefsSettings: securePrefsSettings,
prefsSettings: prefsSettings,
workManagerSettings: workManagerSettings,
webSettings: webSettings,
assert(
(appRunner != null && app == null) ||
(appRunner == null && app != null),
'Use either appRunner or app, not both.',
);

final resolvedAppRunner = appRunner ?? () => runApp(app!);

if (sentryOptions != null) {
await SentryFlutter.init(
sentryOptions,
// Run the app after initializing Sentry.
appRunner: () => runApp(app),
// Boot Playx inside Sentry's app runner so binding initialization and
// runApp execute in the same zone, especially on Flutter web.
appRunner: () async {
await boot(
appConfig: appConfig,
themeConfig: themeConfig,
envSettings: envSettings,
localeConfig: localeConfig,
appConfigBuilder: appConfigBuilder,
localeConfigBuilder: localeConfigBuilder,
themeConfigBuilder: themeConfigBuilder,
envSettingsBuilder: envSettingsBuilder,
securePrefsSettings: securePrefsSettings,
prefsSettings: prefsSettings,
workManagerSettings: workManagerSettings,
webSettings: webSettings,
);
await Future<void>.sync(resolvedAppRunner);
},
);
} else {
runApp(app);
await boot(
appConfig: appConfig,
themeConfig: themeConfig,
envSettings: envSettings,
localeConfig: localeConfig,
appConfigBuilder: appConfigBuilder,
localeConfigBuilder: localeConfigBuilder,
themeConfigBuilder: themeConfigBuilder,
envSettingsBuilder: envSettingsBuilder,
securePrefsSettings: securePrefsSettings,
prefsSettings: prefsSettings,
workManagerSettings: workManagerSettings,
webSettings: webSettings,
);
await Future<void>.sync(resolvedAppRunner);
}
}

Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: playx
description: Playx eco system helps with redundant features as it provides many utilities for themes, widgets and more.
version: 2.1.0
version: 2.1.2
homepage: https://sourcya.io
repository: https://github.com/playx-flutter/playx
issue_tracker: https://github.com/playx-flutter/playx/issues
Expand All @@ -23,7 +23,7 @@ dependencies:
playx_theme: ^2.0.0
playx_widget: ^0.5.0
playx_network: ^1.0.0
playx_navigation: ^2.0.0
playx_navigation: ^2.1.0
playx_localization: ^0.4.0
queen_validators: ^1.0.1
sentry_flutter: ^9.17.0
Expand Down
Loading