nearby_cross 1.0.2 copy "nearby_cross: ^1.0.2" to clipboard
nearby_cross: ^1.0.2 copied to clipboard

Flutter plugin for Android and iOS to use Nearby Connections API and send messages between devices.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
import 'package:nearby_cross/constants/app.dart';
import 'package:nearby_cross/models/connections_manager_model.dart';
import 'package:nearby_cross/modules/authentication/experimental/experimental_auth_manager.dart';
import 'package:nearby_cross_example/models/example_authentication_manager.dart';
import 'package:nearby_cross_example/screens/main_screen.dart';

void main() {
  runApp(const MyApp());
  const appMode =
      String.fromEnvironment("APP_MODE", defaultValue: 'experimental');
  Logger().i("Starting app in $appMode mode");

  if (AppMode.values.byName(appMode) == AppMode.experimental) {
    // In experimental mode we let the devices create/retrieve their own Public/Private Keys
    var experimentalAuthManager = ExperimentalAuthManager();
    experimentalAuthManager.setIdentifier('test_experimental');
    ConnectionsManager(authenticationManager: experimentalAuthManager);
  } else {
    // If we are not in experimental mode, we will force devices to use a Public/Private Keys
    // declared in ExampleAuthenticationManager
    const profile = String.fromEnvironment("PROFILE", defaultValue: 'DOCENTE');
    Logger().i("Setting profile: $profile");

    var exampleAuthManager = ExampleAuthenticationManager();
    exampleAuthManager.setIdentifier(exampleAuthManager.devices[profile]!);
    ConnectionsManager(authenticationManager: exampleAuthManager);
  }
}

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

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

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: MainScreen());
  }
}
3
likes
150
points
90
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for Android and iOS to use Nearby Connections API and send messages between devices.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

crypto_keys, device_info_plus, flutter, intl, jwk, logger, permission_handler, plugin_platform_interface, shared_preferences, uuid

More

Packages that depend on nearby_cross