Integrate Smartcar into your Flutter app effortlessly to retrieve vehicle data and trigger actions with our simple and secure car API.
This Flutter plugin is built upon Smartcar's native SDKs for both iOS and Android, ensuring seamless integration with your Flutter app. For more details on Smartcar's native SDKs, you can refer to the official documentation:
- Obtain your
clientId
by registering your application on the Smartcar dashboard. - Set up the required permissions based on your use case.
Add the Smartcar Flutter plugin to your pubspec.yaml
file:
dependencies:
smartcar_flutter: ^1.0.0
Configure Smartcar with your credentials and required permission
await Smartcar.setup(
configuration: const SmartcarConfig(
clientId: "{YOUR_CLIENT_ID}",
redirectUri: "sc{YOUR_CLIENT_ID}://{YOUR_HOST}",
scopes: [SmartcarPermission.readOdometer],
testMode: true,
),
);
Start the Smartcar authentication flow:
await Smartcar.launchAuthFlow();
Subscribe to the onSmartcarResponse stream to receive authentication responses:
Smartcar.onSmartcarResponse.listen((SmartcarAuthResponse response) {
// Handle the authentication response
print("Received Smartcar response: ${response.code}");
});
The plugin supports a variety of permissions, allowing you to access specific vehicle information. For a detailed list, refer to the Smartcar Permissions Documentation.
Here's a quick example demonstrating the Smartcar Flutter plugin usage:
// Initialize Smartcar
await Smartcar.setup(
configuration: const SmartcarConfig(
clientId: "{YOUR_CLIENT_ID}",
redirectUri: "sc{YOUR_CLIENT_ID}://{YOUR_HOST}",
scopes: [SmartcarPermission.readOdometer],
testMode: true,
),
);
// Launch Smartcar authentication flow
await Smartcar.launchAuthFlow();
// Listen for Smartcar responses
Smartcar.onSmartcarResponse.listen((SmartcarAuthResponse response) {
// Handle the authentication response
print("Received Smartcar response: ${response.code}");
});