Skip to main content

silent_android 0.0.2 copy "silent_android: ^0.0.2" to clipboard
silent_android: ^0.0.2 copied to clipboard

unlistedoutdated

Silent SDK is a technical solution for collecting some end user and mobile device data in the host application with minimal influence on the user experience.

example/lib/main.dart

import 'package:customized/customized.dart';
import 'package:flutter/material.dart';
import 'package:silent_android/silent_android.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await SilentAndroid.instance.initialize(
      packageName: 'android-id-app',
      appId: 'appId',
      appSecret: 'appSecret');

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Silent SDK',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Silent SDK'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool _isValidated = false;
  bool _isTelephonyRequested = false;
  bool _isLocationRequested = false;

  void onRequestLocation() async {
    var result = await SilentAndroid.instance.requestLocation();
    setState(() => _isLocationRequested = result);
    print('accepted: $result');
  }

  void onRequestTelephony() async {
    var result = await SilentAndroid.instance.requestTelephony();
    setState(() => _isTelephonyRequested = result);
    print('accepted: $result');
  }

  void onCapture() async {
    var uid = '3593569363956739';
    var loadId = DateTime.now().toIso8601String();

    var result = await SilentAndroid.instance.capture(uid: uid, loadId: loadId);

    print('captured: $result');
  }

  void onInitialize() async {
    await Future.delayed(const Duration(seconds: 2));
    var isValidated = await SilentAndroid.instance.isValidated();
    setState(() => _isValidated = isValidated);
  }

  Widget _itemInfoBody({required String value, required String label}) {
    return Container(
      alignment: Alignment.centerLeft,
      child: Text.rich(TextSpan(children: [
        TextSpan(
            text: label,
            style:
                const TextStyle(fontWeight: FontWeight.bold, fontSize: 18.0)),
        TextSpan(text: ': ', style: const TextStyle(fontSize: 18.0)),
        TextSpan(text: value, style: const TextStyle(fontSize: 18.0))
      ])),
    );
  }

  @override
  void initState() {
    super.initState();
    onInitialize();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Container(
          padding: EdgeInsets.all(18.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              _itemInfoBody(
                  label: 'Silent SDK initialized?', value: '$_isValidated'),
              SizedBox(
                height: 8.0,
              ),
              _itemInfoBody(
                  label: 'Location Requested?', value: '$_isLocationRequested'),
              SizedBox(
                height: 8.0,
              ),
              _itemInfoBody(
                  label: 'Telephony Requested?',
                  value: '$_isTelephonyRequested'),
              SizedBox(
                height: 50.0,
              ),
              DefaultButton(
                text: 'Request Location',
                onPressed: onRequestLocation,
              ),
              SizedBox(
                height: 16.0,
              ),
              DefaultButton(
                text: 'Request Telephony',
                onPressed: onRequestTelephony,
              ),
              SizedBox(
                height: 16.0,
              ),
              DefaultButton(
                text: 'Capture Data',
                onPressed: onCapture,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
0
points
21
downloads

Publisher

verified publisheredvaldomartins.dev

Weekly Downloads

Silent SDK is a technical solution for collecting some end user and mobile device data in the host application with minimal influence on the user experience.

Repository

License

unknown (license)

Dependencies

flutter, plugin_platform_interface, silent_platform_interface

More

Packages that depend on silent_android

Packages that implement silent_android