peer2play_plugin 2.1.5 copy "peer2play_plugin: ^2.1.5" to clipboard
peer2play_plugin: ^2.1.5 copied to clipboard

A Flutter plugin for p2p.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:peer2play_plugin/peer2play_plugin.dart';

void main() async {
  await Peer2playPlugin.initialize();
  runApp(const MyApp());
}

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

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

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: ConnectP2PButton(
            onSuccess: (result) {
              print("Response:: $result");
            },
            onError: (error) {
              print("Response:: $error");
            },
          ),
        ),
      ),
    );
  }
}