用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/googleapis/google-cloud-dart --skill google-cloud-location-setup命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | google-cloud-location-setup |
| description | Use this skill to help the developer get started with package:google_cloud_location |
dart pub add google_cloud_location
In your Dart code, import the library:
import 'package:google_cloud_location/location.dart';
To call the client, you need to create an instance of the service that
you want to use, e.g., Locations.
There are two ways of creating an instance with the necessary credentials.
Recommended for production environments, server-side backends, and when running on Google Cloud (such as Cloud Run, GCE, GKE).
When running on Google Cloud, Application Default Credentials are automatically available.
When running locally, the gcloud command must be available (see
Install the Google Cloud CLI).
To obtain Application Default Credentials, run:
gcloud auth application-default login
Add googleapis_auth to your dependencies:
dart pub add googleapis_auth
import 'package:googleapis_auth/auth_io.dart';
import 'package:google_cloud_location/location.dart';
Future<void> main() async {
final authClient = await clientViaApplicationDefaultCredentials(
scopes: [
'https://www.googleapis.com/auth/cloud-platform',
],
);
final client = Locations(client: authClient);
try {
// Call a method on the client.
final response = await client.getLocation(
GetLocationRequest(),
);
print('Response: $response');
} finally {
// Always close the client to release resources.
client.close();
}
}
Recommended for quick testing or prototyping because the setup is simple.
If the user does not have an API key, then they can obtain one using the Google Cloud Console.
Add the API key to one of these environment variables:
GOOGLE_API_KEYimport 'package:google_cloud_location/location.dart';
Future<void> main() async {
final client = Locations.fromApiKey();
try {
// Call a method on the client.
final response = await client.getLocation(
GetLocationRequest(),
);
print('Response: $response');
} finally {
// Always close the client to release resources.
client.close();
}
}