Getting started Flutter
Best practice: Initialize the Experiences SDK as early as possible when your app loads (for example, in main before runApp). Early initialization improves performance and keeps analytics stable.
Sample app
Public sample app can be found here.
Prerequisites
You must get a WSC API key before you begin.
Install the Flutter SDK
In your pubspec.yaml file add the SDK dependencies that you are planning to use.
dependencies:
# This is the core package which is always needed.
blaze_flutter_sdk:
git:
url: https://github.com/WSCSports/blaze-flutter-packages.git
ref: <VERSION> # Tag version
path: blaze_flutter_sdk
# This is the Google IMA package for showing VAST ads during playback.
blaze_flutter_ima_ads:
git:
url: https://github.com/WSCSports/blaze-flutter-packages.git
ref: <VERSION> # Tag version
path: blaze_flutter_ima_ads
# This is the Google Ads Manager package for showing banner ads and custom native ads during playback.
blaze_flutter_gam_ads:
git:
url: https://github.com/WSCSports/blaze-flutter-packages.git
ref: 0.1.0 # Tag version
path: blaze_flutter_gam_ads
Flutter: Android setup
Generating a GithubPackages token
Our Android library is using GitHub Packages.
Currently, GitHub Packages requires us to authenticate to download an Android Library (Public or Private) hosted on GitHub Packages.
Follow the instructions on the Android native section in order to generate the required token and set it up in the Android project (Steps 1-3). Feel free to check out the sample app to see how it is being done there.
Changes to your MainActivity
Make sure your MainActivity in the app extends FlutterFragmentActivity. Since our native SDK requires native features, the default base class Flutter generates is not enough.
Flutter: iOS setup
In the iOS environment, follow these steps:
Add source to the top part of your Podfile
Sample Podfile:
source 'https://github.com/WSCSports/blaze-specs-ios.git'
...How to use
Import the SDK
import 'package:blaze_flutter_sdk/blaze_flutter_sdk.dart';Initialize the SDK
During app launch, initiate our SDK module, and replace '<API_KEY>' with the api key that was provided to you.
// Initialize the Blaze SDK.
Future<void> initBlazeSDK() async {
try {
final isBlazeSDKInitialized = await BlazeSDK.isInitialized();
if (!isBlazeSDKInitialized) {
await BlazeSDK.initSDK(
apiKey: '<API_KEY>',
cachingSize: 512,
cachingLevel: BlazeCachingLevel.defaultLevel,
// defaultStoryPlayerStyle: testStoryPlayerStyle,
// defaultMomentsPlayerStyle: testMomentsPlayerStyle,
// defaultVideosPlayerStyle: testVideosPlayerStyle,
globalDelegate: sdk_utils.globalDelegate,
playerEntryPointDelegate: sdk_utils.playerEntryPointDelegate);
}
} catch (e) {
debugPrint('BlazeSDK.init error: $e');
}
}Updated 16 days ago
