{"id":32290820,"url":"https://github.com/pr1sm/history_dart","last_synced_at":"2025-10-23T02:58:18.412Z","repository":{"id":56832407,"uuid":"139186948","full_name":"pr1sm/history_dart","owner":"pr1sm","description":"Abstraction of HTML5 History API for use in any environment","archived":false,"fork":false,"pushed_at":"2019-09-07T04:02:59.000Z","size":156,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-23T02:58:16.263Z","etag":null,"topics":["dart","dart-library","dart-vm","dart-web","history","web"],"latest_commit_sha":null,"homepage":"https://pub.dartlang.org/packages/history","language":"Dart","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/pr1sm.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}},"created_at":"2018-06-29T19:17:51.000Z","updated_at":"2019-09-07T12:55:05.000Z","dependencies_parsed_at":"2022-09-08T01:11:49.854Z","dependency_job_id":null,"html_url":"https://github.com/pr1sm/history_dart","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/pr1sm/history_dart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr1sm%2Fhistory_dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr1sm%2Fhistory_dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr1sm%2Fhistory_dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr1sm%2Fhistory_dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pr1sm","download_url":"https://codeload.github.com/pr1sm/history_dart/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr1sm%2Fhistory_dart/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280551635,"owners_count":26349597,"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-23T02:00:06.710Z","response_time":142,"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":["dart","dart-library","dart-vm","dart-web","history","web"],"created_at":"2025-10-23T02:58:17.330Z","updated_at":"2025-10-23T02:58:18.407Z","avatar_url":"https://github.com/pr1sm.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Pub](https://img.shields.io/pub/v/history.svg)](https://pub.dartlang.org/packages/history)\n[![Build Status](https://travis-ci.com/pr1sm/history_dart.svg?branch=master)](https://travis-ci.com/pr1sm/history_dart)\n[![codecov](https://codecov.io/gh/pr1sm/history_dart/branch/master/graph/badge.svg)](https://codecov.io/gh/pr1sm/history_dart)\n\n# History\n\n`history` lets you manage session history in any environment. It uses a subset of the HTML5 session history API and brings it to the VM and Browsers that don't support session History manipulation. `history` abstracts away the differences in environments using a minimal API. This lets you easily change the history stack, navigate to different locations in your app, confirm navigation changes using custom prompts, and persist any custom state you want between sessions. \n\n## Usage\n\n`history` provides 3 variants to use based on your environment:\n\n- `MemoryHistory` - For use in non-DOM environments such as the dart vm. All session information is stored in memory. This variant can be used in the browser if needed.\n- `BrowserHistory` - For use in modern browsers that support the HTML5 session history API. session information is stored using the browser's history API, allowing history manipulation from other sources to be synced with this `history`.\n- `HashHistory` - For use in legacy browsers. Relies on the hash-based paths and syncs with the browsers `hashchange` events. Custom states are not supported.\n\nTo use `history`, simply import and go!\n```dart\n// For use in Browser\nimport 'package:history/history.dart';\n// For use in VM\n// import 'package:history/vm.dart'; \n\nConfirmation confirmation = (_) =\u003e Future.value(true);\nMemoryHistory history = MemoryHistory(getConfirmation: confirmation);\n\n// Listen for changes\nvar sub = history.onChange.listen((updatedHistory) {\n  var location = updatedHistory.location;\n  print('Transitioned to ${location.path} with action ${updatedHistory.action}!');\n  print('State associated with this location: ${location.state}');\n});\n\n// Manipulate the history\nawait history.push('/first');\nawait history.push('/second', 'with a state');\nawait history.replace('/third', {'with': 'a', 'state': 'object'});\nawait history.goBack();\nawait history.goForward();\nawait history.go(-1);\n\n// Block transitions until they are confirmed by the user\nhistory.block('Are you sure you want to navigate?');\n\n// This call waits for a user confirmation before continuing\nawait history.push('/confirmed');\n\n// Use a more complex Prompt for more flexibilty\nPrompt prompt = (Location l, Action a) {\n  if (l.path == '/logout') {\n    return Future.value('Logging out will cause you to lose all unsaved data!');\n  } else if (a == Action.pop) {\n    return Future.value('Are you sure you want to go back?');\n  }\n  return Future.value('Are you sure you want to navigate?');\n};\nhistory.block(prompt);\n\n// Prints different prompts based on the transition\nawait history.goBack();\nawait history.push('/logout');\n\n// Return to non-blocking mode\nhistory.unblock();\n\n// Stop listening\nawait sub.cancel();\n```\n\n## Examples\nExamples are available in the `examples/` folder -- one for each type of `history` variant.\n- For Browser Examples, run `pub get` and `pub run build_runner serve example`. Then navigate to `localhost:8080`\n- For a VM Example, run `pub get` then run `dart example/example_vm.dart`\n\n## Inspiration\n\nThis project is largely based on [`history`](https://www.npmjs.com/package/history), an npm package provided by [React Training](https://reacttraining.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpr1sm%2Fhistory_dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpr1sm%2Fhistory_dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpr1sm%2Fhistory_dart/lists"}