flutter_app_preferences 0.4.1 copy "flutter_app_preferences: ^0.4.1" to clipboard
flutter_app_preferences: ^0.4.1 copied to clipboard

A simple package to manage app preferences and get notifications when something changes.

example/lib/main.dart

import 'package:example/app_preferences.dart';
import 'package:flutter/material.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await AppPreferences.i.initialize();

  runApp(
    MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    ),
  );
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('App Preferences Example'),
      ),
      body: ListenableBuilder(
        listenable: AppPreferences.i.counter,
        builder: (context, _) => Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Text(
                'You have pushed the button this many times:',
              ),
              Text(
                '${AppPreferences.i.counter.value}',
                style: Theme.of(context).textTheme.headlineMedium,
              ),
            ],
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => AppPreferences.i.counter.value += 1,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
1
likes
160
points
44
downloads

Publisher

verified publishernikodembernat.com

Weekly Downloads

A simple package to manage app preferences and get notifications when something changes.

Homepage
Repository (GitHub)
View/report issues

Topics

#persistence #shared-preferences #storage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on flutter_app_preferences