finbox_dc_plugin 0.0.6 copy "finbox_dc_plugin: ^0.0.6" to clipboard
finbox_dc_plugin: ^0.0.6 copied to clipboard

outdated

Device Connect Flutter SDK is used to collect anonymised non-PII data from the devices of the users after taking explicit user consent

example/lib/main.dart

import 'package:either_dart/either.dart';
import 'package:finbox_dc_plugin/finbox_dc_plugin.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  String _deviceConnectValue = "";
  static String customerId = 'customer_id';
  static String apiKey = 'api_key';

  _createUser() {
    try {
      final hello = FinBoxDcPlugin.createUser(apiKey, customerId);
      hello.fold(
          (left) => {
                // error response
              },
          (right) => {
                // success response
              });
    } on PlatformException catch (e) {
      _deviceConnectValue = 'Failed to fetch data';
    }
  }

  _startPeriodicSync() {
    FinBoxDcPlugin.startPeriodicSync();
  }

  _stopPeriodicSync() {
    FinBoxDcPlugin.stopPeriodicSync();
  }

  _setSyncFrequency() {
    FinBoxDcPlugin.setSyncFrequency(36000);
  }

  _resetData() {
    FinBoxDcPlugin.resetData();
  }

  _setDeviceMatch() {
    FinBoxDcPlugin.setDeviceMatch("email", "userName", "phone");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Device Connect Sample"),
      ),
      body: Center(
        child: Column(
          children: [
            RaisedButton(
              onPressed: _createUser,
              child: Text("Create User"),
            ),
            RaisedButton(
              onPressed: _setDeviceMatch,
              child: Text("Set Device Data"),
            ),
            RaisedButton(
              onPressed: _setSyncFrequency,
              child: Text("Set Sync Frequency"),
            ),
            RaisedButton(
              onPressed: _startPeriodicSync,
              child: Text("Start Periodic Sync"),
            ),
            RaisedButton(
              onPressed: _stopPeriodicSync,
              child: Text("Stop Periodic Sync"),
            ),
            RaisedButton(
              onPressed: _resetData,
              child: Text("Reset Data"),
            ),
          ],
        ),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
0
likes
30
points
1.35k
downloads

Publisher

verified publisherfinbox.in

Weekly Downloads

Device Connect Flutter SDK is used to collect anonymised non-PII data from the devices of the users after taking explicit user consent

Repository (GitLab)

License

unknown (license)

Dependencies

either_dart, flutter

More

Packages that depend on finbox_dc_plugin

Packages that implement finbox_dc_plugin