flutter_app_preferences 0.3.0 copy "flutter_app_preferences: ^0.3.0" to clipboard
flutter_app_preferences: ^0.3.0 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
0
pub points
25%
popularity

Publisher

verified publishernikodembernat.com

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

Homepage

License

unknown (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on flutter_app_preferences