Core package for the PlayX ecosystem containing shared classes and utilities.
- Dependency Injection: Manage your dependencies using
GetIt
. - PlayxPrefs: Key-value storage powered by
SharedPreferences
. - PlayxSecurePrefs: Encrypted key-value storage powered by
FlutterSecureStorage
. - PlayxAsyncPrefs: Asynchronous key-value storage for non-blocking operations.
- PlayxPrefsWithCache: Key-value storage with caching capabilities for improved performance.
- PlayxEnv: Configure your application with global variables using a
.env
file. - bootCore Function: Set up and initialize essential components for the PlayX ecosystem.
Add playx_core
to your pubspec.yaml
dependencies:
dependencies:
playx_core: ^0.5.4
Initialize the PlayX core in your main
function:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Boot the core
await PlayxCore.bootCore(
securePrefsSettings: PlayxSecurePrefsSettings(),
createPlayxPrefs: true,
createPlayxAsyncPrefs: true,
createPlayxPrefsWithCache: true,
);
// Run the app
runApp(const MyApp());
}
To use dependency injection, access the GetIt
instance:
// Register services
getIt.registerSingleton<MyService>(MyService());
// Retrieve services
MyService myService = getIt<MyService>();
Store and retrieve data using PlayxPrefs
:
// Store data
PlayxPrefs.setString('name','John Doe');
PlayxPrefs.setInt('age', 25);
PlayxPrefs.setDouble('height', 5.8);
// Retrieve data
String name = PlayxPrefs.getString('name');
int age = PlayxPrefs.getInt('age');
double? height = PlayxPrefs.maybeGetDouble('height');
Use PlayxSecurePrefs
for encrypted storage:
// Store data securely
await PlayxSecurePrefs.setString('secureName','Jane Doe');
// Retrieve data securely
String secureName = await PlayxSecurePrefs.getString('secureName');
For asynchronous key-value storage, use PlayxAsyncPrefs
:
// Store data asynchronously
await PlayxAsyncPrefs.setString('asyncName','Async John');
// Retrieve data asynchronously
String asyncName = await PlayxAsyncPrefs.getString('asyncName');
Utilize PlayxPrefsWithCache
for caching preferences:
// Store data with caching
await PlayxPrefsWithCache.setString('cachedName','Cached Jane');
// Retrieve data with cache
String cachedName = await PlayxPrefsWithCache.getString('cachedName');
For detailed documentation on using PlayX Core, visit
the documentation.
For questions, issues, or feature requests, please visit
the GitHub repository. Contributions are welcome!
- Playx: The PlayX ecosystem for redundant features, reduced code,
and improved productivity. - Playx_theme: Multi-theme features for Flutter apps.
- Playx_localization: Localization and
internationalization for Flutter apps.
This project is licensed under the MIT License - see
the LICENSE file for details.