singularity_flutter 1.1.0 copy "singularity_flutter: ^1.1.0" to clipboard
singularity_flutter: ^1.1.0 copied to clipboard

retractedoutdated

A Flutter plugin for Singularity. It provide easy integration of login and wallet connection.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:singularity_flutter/SingularityFlutter.dart';

void main() {
  runApp(MaterialApp(home: MyApp()));
}

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

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

class _MyAppState extends State<MyApp> implements SigularitySDKProtocol {
  /// take variable of SingularityFlutter
  late SingularityFlutter _gamepay;

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

    /// initalize variable of SingularityFlutter
    _gamepay = SingularityFlutter(this);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Niobrix'),
        ),
        body: Center(
          child: ElevatedButton(
            child: const Text("Start"),
            onPressed: () async {
              /// call SingularityFlutter openLoginScreen to start login flow
              _gamepay.openLoginScreen(key: "neobrix", singularityConfig: {});
            },
          ),
        ),
      ),
    );
  }

  showAlertDialog(BuildContext context, String title, String content) {
    Widget okButton = TextButton(
      child: const Text("OK"),
      onPressed: () {
        Navigator.pop(context);
      },
    );

    showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: Text(title),
            content: SingleChildScrollView(
              scrollDirection: Axis.vertical,
              child: new Text(content),
            ),
            actions: [okButton],
          );
        });
  }

  /// Sigularity delegate method after login success
  @override
  onGetSingularityUserInfo(String user) {
    showAlertDialog(context, "onGetSingularityUserInfo", user.toString());
  }

  ///Sigularity delegate method when user click on close or back button
  @override
  onSingularityClose() {
    showAlertDialog(context, "onSigularityClose", "Back Pressed");
  }

  /// Sigularity delegate method after logout success
  @override
  onSingularityLogout() {
    showAlertDialog(context, "onSigularityLogout", "onSigularityLogout");
  }
}
1
likes
0
points
40
downloads

Publisher

verified publisherneobrix.io

Weekly Downloads

A Flutter plugin for Singularity. It provide easy integration of login and wallet connection.

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on singularity_flutter