sentiance_flutter 0.0.1 copy "sentiance_flutter: ^0.0.1" to clipboard
sentiance_flutter: ^0.0.1 copied to clipboard

Flutter plugin for Sentiance

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:sentiance_flutter/sentiance_flutter.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: _getPaymentMethodOption(context),
      ),
    );
  }

  String token = // we get the token from the app
      "TOKEN";
  String sentianceSecret = "SECRET"; //constant
  String appId = "APPLICATION ID"; // constant
  String userLinkUrl = "USER LINKING URL"; // constant
  String crashDetectionUrl = "CRASH DETECTION URL"; // constant
  String mobileHealthUrl = "MOBILE HEALTH URL"; //constant

  // used for the payment option
  Widget _getPaymentMethodOption(
    BuildContext context,
  ) {
    return Container(
      alignment: Alignment.center,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          ElevatedButton(
              onPressed: () async {
                await SentianceFlutter.initialiseSentiance(
                    token: token,
                    sentianceSecret: sentianceSecret,
                    appId: appId,
                    userLinkUrl: userLinkUrl,
                    crashDetectionUrl: crashDetectionUrl,
                    mobileHealthUrl: mobileHealthUrl);
              },
              child: const Text(
                "Initialise SDK",
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 16.0,
                  fontWeight: FontWeight.bold,
                ),
              )),
          ElevatedButton(
              onPressed: () async {
                MobileHealthData data =
                    await SentianceFlutter.getMobileHealthData;
                if (kDebugMode) {
                  print(data.androidsdkVersion);
                }
              },
              child: const Text("Get Mobile Health Data",
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 16.0,
                    fontWeight: FontWeight.bold,
                  ))),
          ElevatedButton(
              onPressed: () async {
                await SentianceFlutter.stopSentianceSDK;
              },
              child: const Text(
                "Stop SDK",
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 16.0,
                  fontWeight: FontWeight.bold,
                ),
              )),
        ],
      ),
    );
  }
}
1
likes
120
pub points
0%
popularity

Publisher

unverified uploader

Flutter plugin for Sentiance

Homepage

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

background_locator, flutter

More

Packages that depend on sentiance_flutter