Skip to content

Commit

Permalink
Android: functions to turn on/off bluetooth - example
Browse files Browse the repository at this point in the history
  • Loading branch information
officelioneight committed Sep 29, 2021
1 parent aab5e44 commit b31bd47
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'dart:io';
import 'dart:math';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -57,6 +58,12 @@ class BluetoothOffScreen extends StatelessWidget {
.subtitle2
?.copyWith(color: Colors.white),
),
ElevatedButton(
child: Text('TURN ON'),
onPressed: Platform.isAndroid
? () => FlutterBlue.instance.turnOn()
: null,
),
],
),
),
Expand All @@ -70,6 +77,18 @@ class FindDevicesScreen extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: Text('Find Devices'),
actions: [
ElevatedButton(
child: Text('TURN OFF'),
style: ElevatedButton.styleFrom(
primary: Colors.black,
onPrimary: Colors.white,
),
onPressed: Platform.isAndroid
? () => FlutterBlue.instance.turnOff()
: null,
),
],
),
body: RefreshIndicator(
onRefresh: () =>
Expand Down

0 comments on commit b31bd47

Please sign in to comment.