import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; class BluetoothOffScreen extends StatelessWidget { const BluetoothOffScreen({Key key, this.adapterState}) : super(key: key); final BluetoothAdapterState adapterState; @override Widget build(BuildContext context) { return ScaffoldMessenger( child: Scaffold( backgroundColor: Colors.lightBlue, body: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ const Icon( Icons.bluetooth_disabled, size: 200.0, color: Colors.white54, ), Text( 'Bluetooth Adapter is ${adapterState != null ? adapterState.toString().split(".").last + ", Please turn on your bluetooth to continue." : 'not available'}.', textAlign: TextAlign.center, style: Theme.of(context).primaryTextTheme.titleSmall?.copyWith(color: Colors.white), ), if (Platform.isAndroid) ElevatedButton( child: const Text('TURN ON'), onPressed: () async { try { if (Platform.isAndroid) { await FlutterBluePlus.turnOn(); } } catch (e) {} }, ), ], ), ), ), ); } }