flutterx_preferences 2.0.0 copy "flutterx_preferences: ^2.0.0" to clipboard
flutterx_preferences: ^2.0.0 copied to clipboard

Persistent and session key-value storage exposed as a synchronous Map<String, String>, with typed accessors for bool, int, double, JSON and lists.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutterx_preferences/flutterx_preferences.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Preferences.initialize();
  runApp(const ExampleApp());
}

/// Counter whose value survives restarts.
class ExampleApp extends StatefulWidget {
  /// Creates the example app.
  const ExampleApp({super.key});

  @override
  State<ExampleApp> createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
  final Preferences _preferences = Preferences.local('example');

  @override
  Widget build(BuildContext context) => MaterialApp(
    title: 'Flutterx Preferences',
    home: Scaffold(
      appBar: AppBar(title: const Text('Preferences example')),
      body: Center(child: Text('Pressed ${_preferences.getInt('counter')} times')),
      floatingActionButton: FloatingActionButton(
        onPressed: () => setState(() => _preferences.setInt('counter', _preferences.getInt('counter') + 1)),
        child: const Icon(Icons.add),
      ),
    ),
  );
}
1
likes
160
points
120
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Persistent and session key-value storage exposed as a synchronous Map<String, String>, with typed accessors for bool, int, double, JSON and lists.

Repository (GitLab)
View/report issues

License

BSD-3-Clause (license)

Dependencies

flutter, path_provider, web

More

Packages that depend on flutterx_preferences