From 5b8922e68ac172b7252e1d59028a34a3aadf61b7 Mon Sep 17 00:00:00 2001 From: Thomas Atkins Date: Sat, 10 Apr 2021 14:48:24 -0500 Subject: [PATCH] working on --- loc_chain_app/lib/pages/bluetooth.dart | 21 +++++++++++++++++++-- loc_chain_app/lib/util/bluetooth.dart | 10 ++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 loc_chain_app/lib/util/bluetooth.dart diff --git a/loc_chain_app/lib/pages/bluetooth.dart b/loc_chain_app/lib/pages/bluetooth.dart index af5dd28..c2fa57b 100644 --- a/loc_chain_app/lib/pages/bluetooth.dart +++ b/loc_chain_app/lib/pages/bluetooth.dart @@ -16,7 +16,9 @@ class BluetoothPage extends StatefulWidget { } class _BluetoothPageState extends State { - final id = SharedPreferences.getInstance().then((s) => s.getString('id')); + // final String id = getId(); + // String getId() => + // SharedPreferences.getInstance().then((s) => s.getString('id') ?? '0'); @override Widget build(BuildContext context) { @@ -25,8 +27,23 @@ class _BluetoothPageState extends State { title: Text(widget.title), ), body: Center( - child: Text('$id'), + child: ElevatedButton( + child: Text("GetID"), + onPressed: () async { + final prefs = await SharedPreferences.getInstance(); + final id = prefs.getString('id'); + + ScaffoldMessenger.of(context) + .showSnackBar(SnackBar(content: Text("Id is $id"))); + }, + ), ), ); } + + void showSnackbar(dynamic a) { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text(a.toString()), + )); + } } diff --git a/loc_chain_app/lib/util/bluetooth.dart b/loc_chain_app/lib/util/bluetooth.dart new file mode 100644 index 0000000..c5ad77a --- /dev/null +++ b/loc_chain_app/lib/util/bluetooth.dart @@ -0,0 +1,10 @@ +import 'dart:io'; +import 'dart:math'; +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; +import 'package:nearby_connections/nearby_connections.dart'; + +import 'package:shared_preferences/shared_preferences.dart'; + +class Connect {}