Skip to content

Instantly share code, notes, and snippets.

@JCKodel
Created April 9, 2023 21:21
Show Gist options
  • Save JCKodel/746232db7b0d941947392da7168dcb93 to your computer and use it in GitHub Desktop.
Save JCKodel/746232db7b0d941947392da7168dcb93 to your computer and use it in GitHub Desktop.
pub.dev api sample
{
"gitHubRepo": {
"url": "https://api.github.com/repos/zeexan-dev/detect_fake_location",
"htmlUrl": "https://github.com/zeexan-dev/detect_fake_location",
"cloneUrl": "https://github.com/zeexan-dev/detect_fake_location.git",
"gitUrl": "git://github.com/zeexan-dev/detect_fake_location.git",
"sshUrl": "git@github.com:zeexan-dev/detect_fake_location.git",
"svnUrl": "https://github.com/zeexan-dev/detect_fake_location",
"mirrorUrl": null,
"id": 625659193,
"nodeId": "R_kgDOJUrNOQ",
"owner": {
"permissions": null,
"siteAdmin": false,
"suspendedAt": null,
"suspended": false,
"ldapDistinguishedName": null,
"updatedAt": "0001-01-01T00:00:00+00:00",
"avatarUrl": "https://avatars.githubusercontent.com/u/6541601?v=4",
"bio": null,
"blog": null,
"collaborators": null,
"company": null,
"createdAt": "0001-01-01T00:00:00+00:00",
"diskUsage": null,
"email": null,
"followers": 0,
"following": 0,
"hireable": null,
"htmlUrl": "https://github.com/zeexan-dev",
"id": 6541601,
"nodeId": "MDQ6VXNlcjY1NDE2MDE=",
"location": null,
"login": "zeexan-dev",
"name": null,
"type": 0,
"ownedPrivateRepos": 0,
"plan": null,
"privateGists": null,
"publicGists": 0,
"publicRepos": 0,
"totalPrivateRepos": 0,
"url": "https://api.github.com/users/zeexan-dev"
},
"name": "detect_fake_location",
"fullName": "zeexan-dev/detect_fake_location",
"isTemplate": false,
"description": "Flutter plugin that detects if the user is using a fake(mock or simulated) location on their device.",
"homepage": null,
"language": "Dart",
"private": false,
"fork": false,
"forksCount": 0,
"stargazersCount": 0,
"watchersCount": 0,
"defaultBranch": "main",
"openIssuesCount": 0,
"pushedAt": "2023-04-09T20:29:09+00:00",
"createdAt": "2023-04-09T19:42:22+00:00",
"updatedAt": "2023-04-09T19:51:28+00:00",
"permissions": {
"admin": false,
"maintain": false,
"push": false,
"triage": false,
"pull": true
},
"parent": null,
"source": null,
"license": {
"key": "bsd-3-clause",
"nodeId": "MDc6TGljZW5zZTU=",
"name": "BSD 3-Clause \u0022New\u0022 or \u0022Revised\u0022 License",
"spdxId": "BSD-3-Clause",
"url": "https://api.github.com/licenses/bsd-3-clause",
"featured": false
},
"hasIssues": true,
"hasWiki": false,
"hasDownloads": true,
"allowRebaseMerge": null,
"allowSquashMerge": null,
"allowMergeCommit": null,
"hasPages": false,
"subscribersCount": 1,
"size": 165,
"archived": false,
"topics": [],
"deleteBranchOnMerge": null,
"visibility": 0,
"allowAutoMerge": null,
"allowUpdateBranch": null
},
"name": "detect_fake_location",
"latest": {
"version": "0.0.2",
"pubspec": {
"name": "detect_fake_location",
"description": "A Flutter plugin for detecting if location is being simulated or faked",
"version": "0.0.2",
"homepage": "https://github.com/zeexan-dev/detect_fake_location",
"repository": null,
"environment": {
"sdk": "\u003E=2.19.5 \u003C3.0.0",
"flutter": "\u003E=2.5.0"
},
"dependencies": {
"flutter": {
"sdk": "flutter"
},
"plugin_platform_interface": "^2.0.2",
"permission_handler": "^10.2.0"
},
"dev_dependencies": {
"flutter_test": {
"sdk": "flutter"
},
"flutter_lints": "^2.0.0"
}
},
"archive_url": "https://pub.dartlang.org/packages/detect_fake_location/versions/0.0.2.tar.gz",
"package_url": null,
"url": null,
"published": "2023-04-09T20:28:56.3379+00:00"
},
"versions": [
{
"version": "0.0.1",
"pubspec": {
"name": "detect_fake_location",
"description": "A Flutter plugin for detecting if location is being simulated or faked",
"version": "0.0.1",
"homepage": "https://github.com/zeexan-dev/detect_fake_location",
"repository": null,
"environment": {
"sdk": "\u003E=2.19.5 \u003C3.0.0",
"flutter": "\u003E=2.5.0"
},
"dependencies": {
"flutter": {
"sdk": "flutter"
},
"plugin_platform_interface": "^2.0.2",
"permission_handler": "^10.2.0"
},
"dev_dependencies": {
"flutter_test": {
"sdk": "flutter"
},
"flutter_lints": "^2.0.0"
}
},
"archive_url": "https://pub.dartlang.org/packages/detect_fake_location/versions/0.0.1.tar.gz",
"package_url": null,
"url": null,
"published": "2023-04-09T19:44:17.277182+00:00"
},
{
"version": "0.0.2",
"pubspec": {
"name": "detect_fake_location",
"description": "A Flutter plugin for detecting if location is being simulated or faked",
"version": "0.0.2",
"homepage": "https://github.com/zeexan-dev/detect_fake_location",
"repository": null,
"environment": {
"sdk": "\u003E=2.19.5 \u003C3.0.0",
"flutter": "\u003E=2.5.0"
},
"dependencies": {
"flutter": {
"sdk": "flutter"
},
"plugin_platform_interface": "^2.0.2",
"permission_handler": "^10.2.0"
},
"dev_dependencies": {
"flutter_test": {
"sdk": "flutter"
},
"flutter_lints": "^2.0.0"
}
},
"archive_url": "https://pub.dartlang.org/packages/detect_fake_location/versions/0.0.2.tar.gz",
"package_url": null,
"url": null,
"published": "2023-04-09T20:28:56.3379+00:00"
}
],
"readMe": "# detect_fake_location\n\nThis is a Flutter plugin that detects if the user is using a fake(mock or simulated) location on their device.\n\n## Installation\n\nTo use this plugin, add detect_fake_location as a dependency in your pubspec.yaml file.\n\n## Permissions\n\n### iOS\nAdd the following entries to your Info.plist file\n\u0060\u0060\u0060\n\u003Ckey\u003ENSLocationAlwaysUsageDescription\u003C/key\u003E\n\u003Cstring\u003EApp needs access to location when in the background.\u003C/string\u003E\n\u003Ckey\u003ENSLocationWhenInUseUsageDescription\u003C/key\u003E\n\u003Cstring\u003EApp requires access to location when open.\u003C/string\u003E\n\u0060\u0060\u0060\nAdd the following to your Podfile\n\u0060\u0060\u0060\npost_install do |installer|\n installer.pods_project.targets.each do |target|\n flutter_additional_ios_build_settings(target)\n # Start of the permission_handler configuration\n target.build_configurations.each do |config|\n config.build_settings[\u0027GCC_PREPROCESSOR_DEFINITIONS\u0027] ||= [\n \u0027$(inherited)\u0027,\n # dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]\n \u0027PERMISSION_LOCATION=1\u0027\n ]\n end\n end\nend\n\u0060\u0060\u0060\n\n### Android\nAdd the ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION and ACCESS_MOCK_LOCATION permission to your Android Manifest.\n\u0060\u0060\u0060\n\u003Cuses-permission android:name=\u0022android.permission.ACCESS_FINE_LOCATION\u0022 /\u003E\n\u003Cuses-permission android:name=\u0022android.permission.ACCESS_COARSE_LOCATION\u0022 /\u003E\n\u003Cuses-permission android:name=\u0022android.permission.ACCESS_MOCK_LOCATION\u0022 /\u003E\n\u0060\u0060\u0060\n\n## Usage\nImport the package with:\n\n\u0060\u0060\u0060\nimport \u0027package:detect_fake_location/detect_fake_location.dart\u0027;\n\u0060\u0060\u0060\n\nThen you can use the following method to check if the user is using a fake location:\n\n\u0060\u0060\u0060\nbool isFakeLocation = await DetectFakeLocation().detectFakeLocation();\n\u0060\u0060\u0060\n\n## Example\n\u0060\u0060\u0060\nimport \u0027package:flutter/material.dart\u0027;\nimport \u0027package:detect_fake_location/detect_fake_location.dart\u0027;\n\nvoid main() {\n runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n title: \u0027My App\u0027,\n home: MyHomePage(),\n );\n }\n}\n\nclass MyHomePage extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return Scaffold(\n appBar: AppBar(\n title: Text(\u0027My App\u0027),\n ),\n body: Center(\n child: ElevatedButton(\n child: Text(\u0027Detect Fake Location\u0027),\n onPressed: () async {\n bool isFakeLocation =\n await DetectFakeLocation().detectFakeLocation();\n showDialog(\n context: context,\n builder: (BuildContext context) {\n return AlertDialog(\n title: Text(\u0027Fake Location Detected\u0027),\n content: Text(\n \u0027The user is${isFakeLocation ? \u0027\u0027 : \u0027 not\u0027} using a fake location.\u0027),\n actions: \u003CWidget\u003E[\n TextButton(\n child: Text(\u0027OK\u0027),\n onPressed: () {\n Navigator.of(context).pop();\n },\n ),\n ],\n );\n },\n );\n },\n ),\n ),\n );\n }\n}\n\n\u0060\u0060\u0060\n\n![Image 1](https://user-images.githubusercontent.com/6541601/230794507-3ebf98ff-6cb5-4fae-b713-b1ab4e425308.PNG)\n![Image 2](https://user-images.githubusercontent.com/6541601/230794510-159d7dbc-d762-45fc-8b08-6fcfb293a458.PNG)\n\n## Limitations\nFor Android, the plugin uses the isMockLocationEnabled method to detect if the user is using a fake location. This method requires the ACCESS_MOCK_LOCATION permission, which may not be granted on some devices. In this case, the method will return false.\n\nFor iOS, the plugin uses the CLLocationSourceInformation class to detect if the location is simulated by software or produced by an external accessory. This class is only available on iOS 15 or later.\n\n## Contribute\nContributions are welcome! Please submit issues and pull requests on the GitHub repository.\n\n## Credits\nFor requesting permissions: [permission_handler](https://pub.dev/packages/permission_handler)\n"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment