{"id":15067696,"url":"https://github.com/outdatedguy/internet_connection_checker_plus","last_synced_at":"2025-10-10T05:19:23.224Z","repository":{"id":61975329,"uuid":"506204400","full_name":"OutdatedGuy/internet_connection_checker_plus","owner":"OutdatedGuy","description":"A Flutter package to check your internet connection with sub-second response times, even on mobile networks!","archived":false,"fork":false,"pushed_at":"2025-03-05T11:21:21.000Z","size":512,"stargazers_count":39,"open_issues_count":1,"forks_count":22,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T17:07:57.448Z","etag":null,"topics":["connectivity-checker","flutter","flutter-package","internet","internet-connection-checker","internet-connection-status","internet-connectivity"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/internet_connection_checker_plus","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/OutdatedGuy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":["OutdatedGuy"]}},"created_at":"2022-06-22T10:44:28.000Z","updated_at":"2025-03-31T02:00:47.000Z","dependencies_parsed_at":"2024-06-27T04:58:47.431Z","dependency_job_id":"7feec0c7-d807-4b07-811f-bd502b4c5834","html_url":"https://github.com/OutdatedGuy/internet_connection_checker_plus","commit_stats":{"total_commits":54,"total_committers":3,"mean_commits":18.0,"dds":0.03703703703703709,"last_synced_commit":"9fe007e401c4d95fd92844724bcc283d51d7ec1a"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OutdatedGuy%2Finternet_connection_checker_plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OutdatedGuy%2Finternet_connection_checker_plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OutdatedGuy%2Finternet_connection_checker_plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OutdatedGuy%2Finternet_connection_checker_plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OutdatedGuy","download_url":"https://codeload.github.com/OutdatedGuy/internet_connection_checker_plus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247694876,"owners_count":20980733,"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":["connectivity-checker","flutter","flutter-package","internet","internet-connection-checker","internet-connection-status","internet-connectivity"],"created_at":"2024-09-25T01:25:56.768Z","updated_at":"2025-10-10T05:19:23.217Z","avatar_url":"https://github.com/OutdatedGuy.png","language":"Dart","readme":"# Internet Connection Checker Plus\n\nA Flutter package to check your internet connection with subsecond response\ntimes, even on mobile networks!\n\n[![pub package][package_svg]][package] [![GitHub][license_svg]](LICENSE)\n\n[![GitHub issues][issues_svg]][issues]\n[![GitHub issues closed][issues_closed_svg]][issues_closed]\n\n\u003chr /\u003e\n\nThis library provides functionality to monitor and verify internet connectivity\nby checking reachability to various URIs. It relies on the `connectivity_plus`\npackage for listening to connectivity changes and the `http` package for making\nnetwork requests.\n\n## Features\n\n- ✅ Check internet connectivity status\n- ✅ Listen to internet connectivity changes\n- ✅ Customizable endpoints and success criteria\n- ✅ Customizable connectivity check logic\n\n## Supported Platforms\n\n|      Features      | Android | iOS | macOS | Linux | Windows | Web |\n| :----------------: | :-----: | :-: | :---: | :---: | :-----: | :-: |\n| Check Connectivity |   ✅    | ✅  |  ✅   |  ✅   |   ✅    | ✅  |\n| Listen to Changes  |   ✅    | ✅  |  ✅   |  ✅   |   ✅    | ✅  |\n\n## Permissions\n\n### Android\n\nAdd the following permission to your `AndroidManifest.xml`:\n\n```xml\n\u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\n```\n\n### macOS\n\nAdd the following to your macOS `.entitlements` files:\n\n```xml\n\u003ckey\u003ecom.apple.security.network.client\u003c/key\u003e\n\u003ctrue/\u003e\n```\n\nFor more information, see the [Flutter Networking Documentation].\n\n## Usage\n\n### Checking for internet connectivity (one-time)\n\nThe simplest way to check if you have internet access:\n\n```dart\nfinal bool isConnected = await InternetConnection().hasInternetAccess;\nif (isConnected) {\n  print('Connected!');\n} else {\n  print('No internet connection.');\n}\n```\n\n### Listening to internet connectivity changes\n\nThe `InternetConnection` class exposes a stream of `InternetStatus` updates,\nallowing you to react to changes in connectivity:\n\n```dart\nfinal subscription = InternetConnection().onStatusChange.listen(\n  (InternetStatus status) {\n    if (status == InternetStatus.connected) {\n      // Internet is connected\n    } else {\n      // Internet is disconnected\n    }\n  },\n);\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e Don't forget to cancel the subscription when it is no longer needed. This will\n\u003e prevent memory leaks and free up resources:\n\u003e\n\u003e ```dart\n\u003e @override\n\u003e void dispose() {\n\u003e   subscription.cancel();\n\u003e   super.dispose();\n\u003e }\n\u003e ```\n\n### Using custom endpoints (URIs)\n\nYou can specify your own endpoints to check for connectivity:\n\n```dart\nfinal connection = InternetConnection.createInstance(\n  customCheckOptions: [\n    InternetCheckOption(uri: Uri.parse('https://example.com')),\n  ],\n);\nfinal isConnected = await connection.hasInternetAccess;\n```\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e - Make sure the endpoints have no caching enabled.\n\u003e - On `web` platform, make sure the endpoints are not CORS blocked.\n\n### Using custom success criteria\n\nYou can define what counts as a successful response:\n\n```dart\nfinal connection = InternetConnection.createInstance(\n  customCheckOptions: [\n    InternetCheckOption(\n      uri: Uri.parse('https://example.com'),\n      responseStatusFn: (response) {\n        return response.statusCode \u003e= 69 \u0026\u0026 response.statusCode \u003c 169;\n      },\n    ),\n    InternetCheckOption(\n      uri: Uri.parse('https://example2.com'),\n      responseStatusFn: (response) =\u003e response.statusCode == 420,\n    ),\n  ],\n);\nfinal isConnected = await connection.hasInternetAccess;\n```\n\n### Using a custom connectivity check method\n\nFor advanced use cases, you can completely customize how connectivity checks are performed by providing your own connectivity checker:\n\n```dart\nfinal connection = InternetConnection.createInstance(\n  customConnectivityCheck: (option) async {\n    // Example: Use the Dio http client\n    try {\n      final dio = Dio();\n      final response = await dio.head(\n        option.uri,\n        options: Options(headers: option.headers, receiveTimeout: option.timeout, validateStatus: (_) =\u003e true),\n      );\n\n      return InternetCheckResult(\n        option: option,\n        isSuccess: response.statusCode == 200,\n      );\n    } catch (_) {\n      return InternetCheckResult(option: option, isSuccess: false);\n    }\n  },\n);\n```\n\nThis customization gives you full control over the connectivity detection process, allowing you to:\n\n- Implement platform-specific network detection\n- Use alternate connectivity checking strategies\n- Implement custom fallback mechanisms\n- Add detailed logging or metrics for connectivity checks\n- Integrate with other network monitoring tools\n\n### Pause and Resume on App Lifecycle Changes\n\nFor situation where you want to pause any network requests when the app goes\ninto the background and resume them when the app comes back into the foreground\n(see [issue #27]):\n\n```dart\nclass MyWidget extends StatefulWidget {\n  const MyWidget({super.key});\n\n  @override\n  State\u003cMyWidget\u003e createState() =\u003e _MyWidgetState();\n}\n\nclass _MyWidgetState extends State\u003cMyWidget\u003e {\n  late final StreamSubscription\u003cInternetStatus\u003e _subscription;\n  late final AppLifecycleListener _listener;\n\n  @override\n  void initState() {\n    super.initState();\n    _subscription = InternetConnection().onStatusChange.listen((status) {\n      // Handle internet status changes\n    });\n    _listener = AppLifecycleListener(\n      onResume: _subscription.resume,\n      onHide: _subscription.pause,\n      onPause: _subscription.pause,\n    );\n  }\n\n  @override\n  void dispose() {\n    _subscription.cancel();\n    _listener.dispose();\n    super.dispose();\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    // Build your widget\n  }\n}\n```\n\n### 8. Using `enableStrictCheck`\n\nThe `enableStrictCheck` option can be used to require that **all** checked URIs\nmust respond successfully for the internet to be considered available. By\ndefault, only one successful response is required.\n\n```dart\nfinal connection = InternetConnection.createInstance(\n  enableStrictCheck: true,\n  customCheckOptions: [\n    InternetCheckOption(uri: Uri.parse('https://example.com')),\n    InternetCheckOption(uri: Uri.parse('https://example2.com')),\n  ],\n);\n```\n\n\u003e [!CAUTION]\n\u003e\n\u003e **Use `enableStrictCheck` only with custom-defined URIs, not with the default\n\u003e ones.**\n\u003e\n\u003e Using it with the default URIs may lead to unreliable results or service\n\u003e outages, as all default endpoints must be up and reachable for a positive\n\u003e result.\n\n## Built-in and Additional URIs\n\n### Default URIs\n\nThe following endpoints are checked by default:\n\n| URI                                          | Description                                                |\n| :------------------------------------------- | :--------------------------------------------------------- |\n| https://one.one.one.one                      | Response time is less than `100ms`, CORS enabled, no-cache |\n| https://icanhazip.com                        | Response time is less than `100ms`, CORS enabled, no-cache |\n| https://jsonplaceholder.typicode.com/todos/1 | Response time is less than `100ms`, CORS enabled, no-cache |\n| https://pokeapi.co/api/v2/ability/?limit=1   | Response time is less than `100ms`, CORS enabled, no-cache |\n\n### More Tested URIs\n\nThe following URIs are tested and work well with the package:\n\n| URI                                        | Description                              |\n| :----------------------------------------- | :--------------------------------------- |\n| https://ipapi.co/ip                        | CORS enabled, no-cache                   |\n| https://api.adviceslip.com/advice          | CORS enabled, no-cache                   |\n| https://api.bitbucket.org/2.0/repositories | CORS enabled, no-cache                   |\n| https://api.thecatapi.com/v1/images/search | CORS enabled, no-cache                   |\n| https://randomuser.me/api/?inc=gender      | CORS enabled, no-cache                   |\n| https://dog.ceo/api/breed/husky/list       | CORS enabled, no-cache                   |\n| https://lenta.ru                           | Russia supported, CORS enabled, no-cache |\n| https://www.gazeta.ru                      | Russia supported, CORS enabled, no-cache |\n\n## If you liked the package, then please give it a [Like 👍🏼][package] and [Star ⭐][repository]\n\n## Credits\n\nThis package is a cloned and modified version of the\n[internet_connection_checker] package, which itself was based on\n[data_connection_checker] (now unmaintained).\n\nThe main goal of this package is to provide a more reliable and faster solution\nfor checking internet connectivity in Flutter applications.\n\n\u003c!-- Badges URLs --\u003e\n\n[package_svg]: https://img.shields.io/pub/v/internet_connection_checker_plus.svg?color=blueviolet\n[license_svg]: https://img.shields.io/github/license/OutdatedGuy/internet_connection_checker_plus.svg?color=purple\n[issues_svg]: https://img.shields.io/github/issues/OutdatedGuy/internet_connection_checker_plus.svg\n[issues_closed_svg]: https://img.shields.io/github/issues-closed/OutdatedGuy/internet_connection_checker_plus.svg?color=green\n\n\u003c!-- Links --\u003e\n\n[Flutter Networking Documentation]: https://docs.flutter.dev/data-and-backend/networking\n[package]: https://pub.dev/packages/internet_connection_checker_plus\n[repository]: https://github.com/OutdatedGuy/internet_connection_checker_plus\n[issues]: https://github.com/OutdatedGuy/internet_connection_checker_plus/issues\n[issues_closed]: https://github.com/OutdatedGuy/internet_connection_checker_plus/issues?q=is%3Aissue+is%3Aclosed\n[internet_connection_checker]: https://github.com/RounakTadvi/internet_connection_checker\n[data_connection_checker]: https://pub.dev/packages/data_connection_checker\n[issue #27]: https://github.com/OutdatedGuy/internet_connection_checker_plus/issues/27\n","funding_links":["https://github.com/sponsors/OutdatedGuy"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutdatedguy%2Finternet_connection_checker_plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foutdatedguy%2Finternet_connection_checker_plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutdatedguy%2Finternet_connection_checker_plus/lists"}