Skip to content

Instantly share code, notes, and snippets.

View sbis04's full-sized avatar

Souvik Biswas sbis04

View GitHub Profile
@sbis04
sbis04 / main.dart
Last active March 4, 2019 17:49
UI Part
...
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
key: _scaffoldKey,
appBar: AppBar(
title: Text("Flutter Bluetooth"),
backgroundColor: Colors.deepPurple,
),
@sbis04
sbis04 / main.dart
Created March 4, 2019 17:14
Bluetooth connection
class _BluetoothAppState extends State<BluetoothApp> {
...
@override
void initState() {
super.initState();
bluetoothConnectionState();
}
// We are using async callback for using await
@sbis04
sbis04 / main.dart
Created March 4, 2019 17:00
BluetoothApp class
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;
@sbis04
sbis04 / main.dart
Created March 4, 2019 16:49
Base code
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(
@sbis04
sbis04 / pubspec.yaml
Created March 4, 2019 16:38
Adding "flutter_bluetooth_serial" dependency
dependencies:
flutter_bluetooth_serial: ^0.0.4