prefman 0.2.0 copy "prefman: ^0.2.0" to clipboard
prefman: ^0.2.0 copied to clipboard

outdated

A Structured Way to manage App Prefernces

example/example.dart

import 'package:prefman/prefman.dart';
import 'package:prefman/src/prefman.dart';

var settings = AppPreferences();

void main() async {
  await PrefMan.initialize();
  var username = settings.username.get();
  settings.username.setValue('new username');
}

class AppPreferences extends SettingManifest {
  final theme = Preference<String>.options(
    key: 'theme',
    defaultValue: 'blue',
    options: [
      Option('blue'),
      Option('red'),
      Option('orange'),
    ],
  );

  final username = Preference<String>.any(
    key: 'username',
    defaultValue: 'user',
  );

  final volume = Preference.integer(
    key: 'volume',
    defaultValue: 10,
    min: 0,
    max: 15,
  );

  final askAgain = Preference.boolean(
    key: 'ask_again',
    defaultValue: true,
  );

  List<Preference> get preferences => [theme, username, volume, askAgain];
}
2
likes
0
points
58
downloads

Publisher

verified publisheraligator.ir

Weekly Downloads

A Structured Way to manage App Prefernces

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on prefman