{"id":20215583,"url":"https://github.com/casdoor/casdoor-flutter-example","last_synced_at":"2025-04-10T14:38:57.654Z","repository":{"id":46213996,"uuid":"515205702","full_name":"casdoor/casdoor-flutter-example","owner":"casdoor","description":"The example code for Casdoor Flutter SDK","archived":false,"fork":false,"pushed_at":"2023-10-20T12:59:10.000Z","size":4572,"stargazers_count":6,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-24T13:11:09.513Z","etag":null,"topics":["auth","authn","casdoor","dart","flutter","iam","oauth","oidc","sdk","sso"],"latest_commit_sha":null,"homepage":"https://github.com/casdoor/casdoor-flutter-sdk","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/casdoor.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-07-18T13:54:55.000Z","updated_at":"2024-12-28T12:24:10.000Z","dependencies_parsed_at":"2024-01-29T00:03:20.832Z","dependency_job_id":null,"html_url":"https://github.com/casdoor/casdoor-flutter-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-flutter-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-flutter-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-flutter-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-flutter-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casdoor","download_url":"https://codeload.github.com/casdoor/casdoor-flutter-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248233984,"owners_count":21069493,"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":["auth","authn","casdoor","dart","flutter","iam","oauth","oidc","sdk","sso"],"created_at":"2024-11-14T06:23:23.013Z","updated_at":"2025-04-10T14:38:57.636Z","avatar_url":"https://github.com/casdoor.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\" style=\"border-bottom: none;\"\u003e📦⚡️Casdoor flutter example\u003c/h1\u003e\n\u003ch3 align=\"center\"\u003eAn example of casdoor-flutter-sdk\u003c/h3\u003e\n\n## \tThe example uses the following Casdoor demo site server:\n\nThe server: https://door.casdoor.com/\n\n## Quick Start\n\n- download the code\n\n```bash\ngit clone git@github.com:casdoor/casdoor-flutter-example.git\n```\n\n- install dependencies\n\n```shell\nflutter pub get\n```\n## Configure\nInitialization requires 6 parameters, which are all str type:\n|  Name (in order)   | Must  | Description |\n|  ----  | ----  |----  |\n| clientId  | Yes | Application.client_id |\n| serverUrl  | Yes | Casdoor Server Url, such as `https://door.casdoor.com` |\n| organizationName  | Yes | Organization name |\n| appName  | Yes | Application name |\n| redirectUri  | Yes | URI of Web redirection |\n| callbackUrlScheme  | Yes | URL Scheme |\n\n```\n  final AuthConfig _config =  AuthConfig(\n      clientId: \"014ae4bd048734ca2dea\",\n      serverUrl: \"https://door.casdoor.com\",\n      organizationName: \"casbin\",\n      appName: \"app-casnode\",\n      redirectUri: \"http://localhost:9000/callback.html\",\n      callbackUrlScheme: \"casdoor\"\n  );\n```\n\n## Run\n\n```\nflutter run -d chrome --web-port 9000\n```\n\n## Notes for different platforms\n\n### Windows 10\n\nDownload the WebView2 runtime from [here](https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section) and install it.\n\nThe WebView2 runtime is included in Windows 11 by default.\n\n## Linux and macOS\n\nAdd the package `desktop_webview_window: ^0.2.3` inside *dependencies* to the *pubspec.yaml* file.\n\nModify the *main* function to look like the following:\n\n```\nvoid main(List\u003cString\u003e args) async {\n  WidgetsFlutterBinding.ensureInitialized();\n  if (runWebViewTitleBarWidget(args)) {\n    return;\n  }\n  runApp(const MyApp());\n}\n```\n\n### Web\nOn the Web platform an endpoint needs to be created that captures the callback URL and sends it to the application using the JavaScript postMessage() method. In the ./web folder of the project, create an HTML file with the name e.g. callback.html with content:\n\n```\n\u003c!DOCTYPE html\u003e\n\u003ctitle\u003eAuthentication complete\u003c/title\u003e\n\u003cp\u003eAuthentication is complete. If this does not happen automatically, please\nclose the window.\n\u003cscript\u003e\n  window.opener.postMessage({\n    'casdoor-auth': window.location.href\n  }, window.location.origin);\n  window.close();\n\u003c/script\u003e\n\n```\nRedirection URL passed to the authentication service must be the same as the URL on which the application is running (schema, host, port if necessary) and the path must point to created HTML file, /callback.html in this case, like  `callbackUri = \"${_config.redirectUri}.html\"`. The callbackUrlScheme parameter of the authenticate() method does not take into account, so it is possible to use a schema for native platforms in the code.It should be noted that when obtaining a token, cross domain may occur\n\nFor the Sign in with Apple in web_message response mode, postMessage from https://appleid.apple.com is also captured, and the authorization object is returned as a URL fragment encoded as a query string (for compatibility with other providers).\n\n## After running, you will see the following  interfaces:\n|  **Android**   | **iOS**  | **Web** |\n|  ----  | ----  |----  |\n| ![Android](screen-andriod.gif) |![iOS](screen-ios.gif)  |![Web](screen-web.gif) |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasdoor%2Fcasdoor-flutter-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasdoor%2Fcasdoor-flutter-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasdoor%2Fcasdoor-flutter-example/lists"}