Flutter Quick Start
Preparations
- Have a Tencent Cloud account;
- Create a CloudBase environment and obtain the Environment ID
- Install Flutter.
Step 1: Create a Flutter Project
flutter create cloudbase_demo
cd cloudbase_demo
Step 2: Add CloudBase Plugin Dependency
Add dependencies
in the project's pubspec.yaml
file.
dependencies:
cloudbase_core: ^0.0.9
cloudbase_auth: ^0.0.11
Install dependencies from pub
.
flutter pub get
Step 3: Create a Mobile Application Security Sources Credential
Go to the Security Settings page and Add Application in the Mobile Application Security Sources section.

Since Flutter is a cross-platform development framework, you need to apply for an application credential for both Android and iOS. The application identifiers should be the Android package name and iOS Bundle ID.
Step 4: Enable Anonymous Login
In the Environment Settings page, click "Login Methods", and then enable anonymous login:

Step 5: Initialize the Environment and Invoke Anonymous Login
In the project's lib/main.dart
file, initialize the environment and perform anonymous login.
import 'package:cloudbase_core/cloudbase_core.dart';
import 'package:cloudbase_auth/cloudbase_auth.dart';
void main() async {
// Initialize CloudBase
CloudBaseCore core = CloudBaseCore.init({
// Fill in your CloudBase env
'env': 'your-env-id',
// Fill in your Mobile Application Security Sources Credential
// The application identifier must be the Android package name or iOS Bundle ID
'appAccess': {
// credentials
'key': 'your-app-access-key',
// Version
'version': 'your-app-access-version'
}
});
// Get the login state
CloudBaseAuth auth = CloudBaseAuth(core);
CloudBaseAuthState authState = await auth.getAuthState();
// Invoke anonymous login
if (authState == null) {
await auth.signInAnonymously().then((success) {
// Login successful
print(success);
}).catchError((err) {
// Login failed
print(err);
});
}
}
The appAccess
parameter used when initializing CloudBase can be obtained from the Security Sources Credentials module in the console.

After successful login, you can access and utilize various resources of Cloud Development. For details, please refer to the Flutter SDK documentation.