{"id":31796239,"url":"https://github.com/iamchathu/flutter_auth_provider","last_synced_at":"2025-10-10T20:43:11.978Z","repository":{"id":47478400,"uuid":"372058458","full_name":"iamchathu/flutter_auth_provider","owner":"iamchathu","description":"Simple and extensible authentication manager for apps built with Flutter.","archived":false,"fork":false,"pushed_at":"2024-03-25T19:48:57.000Z","size":144,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-16T03:27:33.424Z","etag":null,"topics":["auth","authentication","dart","flutter","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamchathu.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-29T19:50:45.000Z","updated_at":"2022-07-09T13:22:34.000Z","dependencies_parsed_at":"2024-03-30T23:00:15.176Z","dependency_job_id":null,"html_url":"https://github.com/iamchathu/flutter_auth_provider","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/iamchathu/flutter_auth_provider","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamchathu%2Fflutter_auth_provider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamchathu%2Fflutter_auth_provider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamchathu%2Fflutter_auth_provider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamchathu%2Fflutter_auth_provider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamchathu","download_url":"https://codeload.github.com/iamchathu/flutter_auth_provider/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamchathu%2Fflutter_auth_provider/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005275,"owners_count":26083864,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["auth","authentication","dart","flutter","hacktoberfest"],"created_at":"2025-10-10T20:43:01.446Z","updated_at":"2025-10-10T20:43:11.974Z","avatar_url":"https://github.com/iamchathu.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flutter_auth_provider\n\nSimple and extensible authentication manager for apps built with Flutter.\n\n## Getting started\n\n### Steps\n\n* Add as a dependency.\n* Implement the Stores.\n* Connect the store to your views.\n\n## Concepts\n\n### 1. Stores\n\nStores are abstract classes that allow you to implement your custom persistence layer for\nauthentication related data.\n\nYou can implement your own authentication persistence logic by implementing the `Stores`.\n\n* AuthStore - This is your user related data store. When you implement the AuthStore, you can also\n  use a custom type for a User specified as a generic.\n* TokenStore - Implement how you store and refresh the token.\n\nExample implementation with `flutter-secure-storage`.\n\n```dart\nimport 'package:flutter_auth_provider/flutter_auth_provider.dart';\nimport 'package:flutter_secure_storage/flutter_secure_storage.dart';\n\nclass User {\n  string userName;\n  string role;\n\n  const User({ required this.role, required this.userName});\n}\n\nconst String userNameKey = 'userName';\nconst String roleKey = 'name';\nconst String tokenKey = 'token';\nconst String refreshTokenKey = 'refreshToken';\n\n\nclass SecureStore implements AuthStore\u003cUser\u003e, TokenStore {\n  static SecureStore _instance = const SecureStore._();\n  final FlutterSecureStorage _storage = const FlutterSecureStorage();\n\n  const SecureStore._();\n\n  factory SecureStore() =\u003e _instance;\n\n  @override\n  Future\u003cvoid\u003e delete() async {\n    await _storage.delete(key: userNameKey);\n    await _storage.delete(key: roleKey);\n  }\n\n  @override\n  Future\u003cUser?\u003e retrieve() async {\n    final userName = await _storage.read(key: userNameKey);\n    final role = await _storage.read(key: roleKey);\n    if (userName != null \u0026\u0026 role != null) {\n      return User(userName: userName, role: role);\n    }\n    return null;\n  }\n\n  @override\n  Future\u003cvoid\u003e save(User user) async {\n    await _storage.write(key: userNameKey, value: user.userName);\n    await _storage.write(key: roleKey, value: user.role);\n  }\n\n  @override\n  Future\u003cvoid\u003e clear() async {\n    await _storage.delete(key: tokenKey);\n    await _storage.delete(key: refreshTokenKey);\n  }\n\n  @override\n  Future\u003cString?\u003e getRefreshToken() async {\n    return _storage.read(key: refreshTokenKey);\n  }\n\n  @override\n  Future\u003cString?\u003e getToken() async {\n    return _storage.read(key: tokenKey);\n  }\n\n  @override\n  Future\u003cvoid\u003e saveTokens({required String token, String? refreshToken}) async {\n    await _storage.write(key: tokenKey, value: token);\n    if (refreshToken != null) {\n      await _storage.write(key: refreshTokenKey, value: refreshToken);\n    }\n  }\n}\n\n```\n\n### 2. Listeners\n\nThere are two listeners available. These will execute your code upon Authentication events. \n\n* LoginListener - Called when user is logged in.\n* LogoutListener - Called when user logs out.\n\nExamples:\n\n* Setting up Sentry with user details.\n* Remove/setup/release resources upon logging out.\n\n## Contributors\n\n* [Chathu Vishwajith](https://github.com/iamchathu)\n* [Pasindu De Silva](https://github.com/pasindud)\n* [Bhagya Nirmaan Silva](https://github.com/bhagyas)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamchathu%2Fflutter_auth_provider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamchathu%2Fflutter_auth_provider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamchathu%2Fflutter_auth_provider/lists"}