Documentation
Search…
Quickstart
​
Flutter Quickstart
Estimated time: 20 minutes
This guide will go over:
    Conditions and minimum requirements
    Installation
    πŸ“¦
    Configuration
    βš™
    Initialization
    ⚑
    Attaching
    πŸ”—
flutter_apm on pub.dev : pub.dev​

Conditions and minimum requirements

Minimum Flutter version : 2.2.3 Minimum Dart version : 2.13.4
Minimum Android version: 4.1 (API 16) Minimum iOS version : 10.0 Minimum XCode version : 10

I. Installation

Download the flutter dependency:
1
flutter pub add flutter_apm
2
flutter pub get
Copied!

II. Configuration

iOS
Android
ios/Podfile Add platform to minimum 10.0 and add sources
1
platform :ios, '10.0'
2
​
3
source 'https://gitlab.appsmiles.eu/appsmiles/APMSpecs.git'
4
source 'https://github.com/CocoaPods/Specs.git'
Copied!
Launch command pod install on folder ios
1
pod install
Copied!
android/build.gradle
1
//You can set login and password in env variables
2
def mavenAppsmilesUsername = System.getenv("APPSMILES_ARTIFACTORY_LOGIN") ?: ''
3
def mavenAppsmilesPassword = System.getenv("APPSMILES_ARTIFACTORY_PASSWORD") ?: ''
4
​
5
//Or in local.properties
6
def folder = new File( 'local.properties' )
7
if( folder.exists() ) {
8
Properties properties = new Properties()
9
properties.load(project.rootProject.file('local.properties').newDataInputStream())
10
mavenAppsmilesUsername = properties.getProperty("maven_appsmiles.username") ?: mavenAppsmilesUsername
11
mavenAppsmilesPassword = properties.getProperty("maven_appsmiles.password") ?: mavenAppsmilesPassword
12
}
13
​
14
allprojects {
15
repositories {
16
//...
17
​
18
maven {
19
url 'https://artifactory.appsmiles.eu/artifactory/list/appsmiles/'
20
credentials {
21
username = mavenAppsmilesUsername
22
password = mavenAppsmilesPassword
23
}
24
}
25
}
26
}
Copied!
android/local.properties If you use a file local.properties, add maven_appsmiles.username and maven_appsmiles.password with your credentials
1
maven_appsmiles.username=USERNAME
2
maven_appsmiles.password=PASSWORD
Copied!

III. Initialization

MainApplication.kt Init the SDK on main thread of your application
1
import android.app.Application
2
import com.moonmiles.apm.sdk.APM
3
​
4
class MyApplication : Application() {
5
override fun onCreate() {
6
super.onCreate()
7
APM.sharedInstance(this) //First init in main thread
8
}
9
}
Copied!
main.dart Initialize the SDK with the keys we provided to you (partnerID, partnerSecret, baseUrl), your app's package name (appId). Add also a instance of APMNavigatorObserver in MaterialApp.navigationObservers
1
import 'package:flutter/material.dart';
2
import 'package:flutter_apm/apm_module.dart';
3
import 'package:flutter_apm/apm_navigator_observer.dart';
4
​
5
void main() {
6
runApp(MyApp());
7
}
8
​
9
APMNavigatorObserver<PageRoute> apmObserver = APMNavigatorObserver<PageRoute>();
10
​
11
class MyApp extends StatelessWidget {
12
@override
13
Widget build(BuildContext context) {
14
15
APMModule.initAppWithAppID('<PARTNER_ID>', '<PARTNER_SECRET>', '<APP_ID>');
16
APMModule.setDebugMode(true);
17
APMModule.setBaseUrl('<BASE_URL>');
18
19
return MaterialApp(
20
title: 'Flutter Demo',
21
theme: ThemeData(
22
primarySwatch: Colors.blue,
23
),
24
home: MyHomePage(title: 'Flutter Demo Home Page'),
25
navigatorObservers: [apmObserver],
26
);
27
}
28
}
Copied!

IV. Attaching

Attach the refresh of the SDK with the lifecycle of your screen

Android

MainActivity.kt

kotlin
java
1
import android.content.Intent
2
import android.os.Bundle
3
import com.moonmiles.apm.sdk.activity.APMClientActivityUtils
4
import io.flutter.embedding.android.FlutterFragmentActivity
5
​
6
class MainActivity: FlutterFragmentActivity() {
7
override fun onCreate(savedInstanceState: Bundle?) {
8
super.onCreate(savedInstanceState)
9
APMClientActivityUtils.onCreate(this)
10
}
11
​
12
override fun onResume() {
13
super.onResume()
14
APMClientActivityUtils.onResume(this)
15
}
16
​
17
override fun onPause() {
18
super.onPause()
19
APMClientActivityUtils.onPause(this)
20
}
21
​
22
override fun onDestroy() {
23
super.onDestroy()
24
APMClientActivityUtils.onDestroy(this)
25
}
26
​
27
override fun onNewIntent(intent: Intent) {
28
super.onNewIntent(intent)
29
APMClientActivityUtils.onNewIntent(this, intent)
30
}
31
}
Copied!
1
TODO
Copied!
Launch the app, you can see appears the badge
Last modified 30d ago