This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
key: _scaffoldKey, | |
appBar: AppBar( | |
title: Text("Flutter Bluetooth"), | |
backgroundColor: Colors.deepPurple, | |
), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _BluetoothAppState extends State<BluetoothApp> { | |
... | |
@override | |
void initState() { | |
super.initState(); | |
bluetoothConnectionState(); | |
} | |
// We are using async callback for using await |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BluetoothApp extends StatefulWidget { | |
@override | |
_BluetoothAppState createState() => _BluetoothAppState(); | |
} | |
class _BluetoothAppState extends State<BluetoothApp> { | |
// Initializing a global key, as it would help us in showing a SnackBar later | |
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); | |
// Get the instance of the bluetooth | |
FlutterBluetoothSerial bluetooth = FlutterBluetoothSerial.instance; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies: | |
flutter_bluetooth_serial: ^0.0.4 |
NewerOlder