{"id":19376311,"url":"https://github.com/cobinja/cobi-flutter-platform-settings","last_synced_at":"2026-05-13T01:33:05.526Z","repository":{"id":56827117,"uuid":"367653799","full_name":"Cobinja/cobi-flutter-platform-settings","owner":"Cobinja","description":"An application settings screen for flutter that persists values via the shared_preferences package and uses the flutter_platform_widgets.","archived":false,"fork":false,"pushed_at":"2023-05-15T12:30:27.000Z","size":100,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-07T04:43:54.221Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cobinja.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-15T14:34:45.000Z","updated_at":"2024-10-23T06:42:49.000Z","dependencies_parsed_at":"2024-11-10T08:43:29.487Z","dependency_job_id":"7c00b2f9-6269-4bbb-831a-61013d246d07","html_url":"https://github.com/Cobinja/cobi-flutter-platform-settings","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"d688768fed99f48cebfae5fd9528930730d87d59"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cobinja%2Fcobi-flutter-platform-settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cobinja%2Fcobi-flutter-platform-settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cobinja%2Fcobi-flutter-platform-settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cobinja%2Fcobi-flutter-platform-settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cobinja","download_url":"https://codeload.github.com/Cobinja/cobi-flutter-platform-settings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240507948,"owners_count":19812884,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T08:43:26.330Z","updated_at":"2026-05-13T01:33:05.518Z","avatar_url":"https://github.com/Cobinja.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cobi_flutter_platform_settings\nAn application settings screen that persists values via the [shared_preferences](https://pub.dev/packages/shared_preferences) package and uses the [flutter_platform_widgets](https://pub.dev/packages/flutter_platform_widgets) for platform integration.\n## Getting Started\nYou can use this anywhere in your app that already uses flutter_platform_widgets.\nIf flutter_platform_widgets is new to you, please read their documentation to get started.\n\nAll widgets come with a property 'settingsKey' which is used to store them in shared_preferences, so you can retrieve the value from anywhere using the same key.\nThe only exceptions from this are PlatformSettingsScreen, PlatformSettingsGroup and PlatformCustomSetting (which is intended to launch navigation routes or to just show some information).\n\nSince v4.0.0 this package supports custom prefixes like the SharedPreferences plugin does since its v2.1.0.\n\n## Widgets\n### PlatformSettingsScreen\nThe uppermost settings container. Use this as a starting point.\n```dart\nPlatformSettingsScreen (\n  title: 'App Settings',\n  children: [],\n)\n```\n### PlatformSettingsGroup\nA container that groups various settings together\n```dart\nPlatformSettingsGroup (\n  title: 'First Group',\n  children: [],\n)\n```\n### PlatformCustomSetting\nA settings widget that takes an onPressed action, useful e.g. to launch navigation routes.\n```dart\nPlatformCustomSetting (\n  title: 'My Custom Setting',\n  subtitle: 'My subtitle',\n  onPressed: () =\u003e debugPrint('hello world!'),\n)\n```\n### PlatformTextSetting\nA widget that shows a textfield\n```dart\nPlatformTextSetting\u003cint\u003e(\n  settingsKey: 'text-setting-3',\n  title: 'A text setting for integers only',\n  keyboardType: TextInputType.number,\n  defaultValue: 42000,\n  validator: (value) {\n    if (value == null || value \u003c 1024 || value \u003e 65536) {\n      return 'Integer number between 1024 and 65536 expected';\n    }\n  },\n),\n```\n### PlatformSwitchSetting\nA widget with a two-state switch\n```dart\nPlatformSwitchSetting(\n  settingsKey: 'switch-setting',\n  title: 'This is a switch setting',\n  defaultValue: true,\n)\n```\n### PlatformCheckboxSetting\nA widget with a checkbox on Android\n*Note: On iOS this uses a switch due to the lack of native checkboxes*\n```dart\nPlatformCheckboxSetting(\n  settingsKey: 'checkbox-setting',\n  title: 'This is a checkbox setting',\n  defaultValue: false,\n),\n```\n### PlatformRadioSetting\nThis shows a list of radio buttons\n```dart\nPlatformRadioSetting\u003cint\u003e(\n  settingsKey:  'radio-setting',\n  title:  'This is a radio setting',\n  items: [\n    PlatformListItem\u003cint\u003e(value: 1, caption: 'One'),\n    PlatformListItem\u003cint\u003e(value: 2, caption: 'Two'),\n    PlatformListItem\u003cint\u003e(value: 3, caption: 'Three'),\n    PlatformListItem\u003cint\u003e(value: 4, caption: 'Four'),\n    PlatformListItem\u003cint\u003e(value: 5, caption: 'Five'),\n  ],\n),\n```\n### PlatformRadioModalSetting\nThe radio buttons in this one are shown in a dialog\n```dart\nPlatformRadioModalSetting\u003cint\u003e(\n  settingsKey: 'radio-modal-setting',\n  title: 'This is a modal radio setting',\n  defaultValue: 5,\n  items: [\n    PlatformListItem\u003cint\u003e(value: 1, caption: 'One'),\n    PlatformListItem\u003cint\u003e(value: 2, caption: 'Two'),\n    PlatformListItem\u003cint\u003e(value: 3, caption: 'Three'),\n    PlatformListItem\u003cint\u003e(value: 4, caption: 'Four'),\n    PlatformListItem\u003cint\u003e(value: 5, caption: 'Five'),\n    PlatformListItem\u003cint\u003e(value: 6, caption: 'Six'),\n  ],\n),\n```\n### PlatformSliderSetting\nYou guessed right, a widget with a slider\n```dart\nPlatformSliderSetting(\n  settingsKey: 'slider-setting',\n  title: 'This is a slider setting',\n  minValue: 0.0,\n  maxValue: 100.0,\n  divisions: 100,\n  defaultValue: 25.0,\n),\n```\n#### You can find more example use cases in the included example app.\n## Extensibility\nYou can define your own widgets by subclassing ``SettingsWidgetBase\u003cT\u003e`` and ``SettingsWidgetBaseState\u003cT, YourSettingsWidgetClass\u003e`` with ``T`` being the type stored via shared_preferences.\n\nIf you need a data type *not* supplied by shared_preferences, you can override ``SettingsWidgetBaseState::serialize()`` and ``SettingsWidgetBaseState::deserialize()`` and do the serialization yourself.\n#### Note: Serialization and deserialization work different in 3.0 compared to version 2.0. See the included example.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcobinja%2Fcobi-flutter-platform-settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcobinja%2Fcobi-flutter-platform-settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcobinja%2Fcobi-flutter-platform-settings/lists"}