xunil_blue_connect 0.0.2+1 copy "xunil_blue_connect: ^0.0.2+1" to clipboard
xunil_blue_connect: ^0.0.2+1 copied to clipboard

outdated

This plugin is bluetooth connect and management.

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: SafeArea(
        child: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin bluetooth check app'),
          ),
          body: const Center(
            child: MainBody(),
          ),
        ),
      ),
    );
  }
}

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

  @override
  State<MainBody> createState() => _BodyState();
}

class _BodyState extends State<MainBody> {
  bool _isBluetoothAvailable = false;

  //call the class
  XunilBlueConnect blueConnect = XunilBlueConnect();

  @override
  Widget build(BuildContext context) {
    return Center(
      child: SizedBox(
        height: MediaQuery.of(context).size.height * 0.33,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Text('Bluetooth is ${_isBluetoothAvailable ? 'ON' : 'OFF'}'),
            ElevatedButton(
              onPressed: () async {
                //call the function but as async
                //but if function return null means the device doesn't support bluetooth
                var isBlue = await blueConnect.isBluetoothAvailable();
                setState(() {
                  _isBluetoothAvailable = isBlue;
                });
              },
              child: const Text('Check'),
            )
          ],
        ),
      ),
    );
  }
}
3
likes
0
pub points
42%
popularity

Publisher

verified publisheralikilic.com.tr

This plugin is bluetooth connect and management.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on xunil_blue_connect