flutter_truecaller 0.2.0+2 copy "flutter_truecaller: ^0.2.0+2" to clipboard
flutter_truecaller: ^0.2.0+2 copied to clipboard

outdated

Truecaller SDK plugin for Flutter apps. Verification via this plugin enables you to quickly verify / signup / login your users on the basis of their mobile number

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_truecaller/flutter_truecaller.dart';

import 'verify_non_truecaller.dart';

void main() => runApp(
      MaterialApp(
        home: MyApp(),
        debugShowCheckedModeBanner: false,
      ),
    );

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _result = 'Unknown';
  final FlutterTruecaller caller = FlutterTruecaller();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Truecaller Plugin Example'),
      ),
      body: SingleChildScrollView(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            OutlineButton(
              onPressed: () async {
                String result = await caller.initializeSDK(
                  sdkOptions: FlutterTruecallerScope.SDK_OPTION_WITH_OTP,
                  footerType: FlutterTruecallerScope.FOOTER_TYPE_ANOTHER_METHOD,
                  consentTitleOptions:
                      FlutterTruecallerScope.SDK_CONSENT_TITLE_VERIFY,
                  consentMode: FlutterTruecallerScope.CONSENT_MODE_POPUP,
                );
                setState(() {
                  _result = result;
                });
              },
              child: Text('Initialize SDK'),
            ),
            OutlineButton(
              onPressed: () async {
                bool isUsable = await caller.isUsable;
                setState(() {
                  _result = isUsable ? "Usable" : "Not usable";
                });
              },
              child: Text('Is usable?'),
            ),
            OutlineButton(
              onPressed: () async {
                String result =
                    await caller.setLocale(FlutterTruecallerLocales.Hindi);
                setState(() {
                  _result = result;
                });
              },
              child: Text('Change Locale'),
            ),
            OutlineButton(
              onPressed: () async {
                await caller.getProfile();
                FlutterTruecaller.manualVerificationRequired.listen((required) {
                  if (required)
                    Navigator.of(context).push(
                      MaterialPageRoute(
                        builder: (_) => Verify(),
                      ),
                    );
                });
              },
              child: Text('Get Profile'),
            ),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Text(_result ?? 'ERROR'),
            ),
            StreamBuilder<String>(
              stream: FlutterTruecaller.callback,
              builder: (context, snapshot) => Text(snapshot.data ?? ''),
            ),
            StreamBuilder<FlutterTruecallerException>(
              stream: FlutterTruecaller.errors,
              builder: (context, snapshot) =>
                  Text(snapshot.hasData ? snapshot.data.errorMessage : ''),
            ),
            StreamBuilder<TruecallerProfile>(
              stream: FlutterTruecaller.trueProfile,
              builder: (context, snapshot) =>
                  Text(snapshot.hasData ? snapshot.data.firstName : ''),
            ),
          ],
        ),
      ),
    );
  }
}
15
likes
0
pub points
35%
popularity

Publisher

unverified uploader

Truecaller SDK plugin for Flutter apps. Verification via this plugin enables you to quickly verify / signup / login your users on the basis of their mobile number

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_truecaller