loc-chain-app/loc_chain_app/lib/pages/bluetooth.dart

50 lines
1.3 KiB
Dart
Raw Normal View History

2021-04-10 18:45:44 +00:00
import 'dart:io';
import 'dart:math';
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:nearby_connections/nearby_connections.dart';
2021-04-10 19:01:03 +00:00
import 'package:shared_preferences/shared_preferences.dart';
2021-04-10 18:45:44 +00:00
class BluetoothPage extends StatefulWidget {
2021-04-10 19:01:03 +00:00
BluetoothPage({Key? key, required this.title}) : super(key: key);
2021-04-10 18:45:44 +00:00
final String title;
@override
_BluetoothPageState createState() => _BluetoothPageState();
}
class _BluetoothPageState extends State<BluetoothPage> {
2021-04-10 19:48:24 +00:00
// final String id = getId();
// String getId() =>
// SharedPreferences.getInstance().then((s) => s.getString('id') ?? '0');
2021-04-10 18:45:44 +00:00
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
2021-04-10 19:01:03 +00:00
body: Center(
2021-04-10 19:48:24 +00:00
child: ElevatedButton(
child: Text("GetID"),
onPressed: () async {
final prefs = await SharedPreferences.getInstance();
2021-04-10 20:19:32 +00:00
final userName = prefs.getString('userName');
2021-04-10 19:48:24 +00:00
ScaffoldMessenger.of(context)
2021-04-10 20:19:32 +00:00
.showSnackBar(SnackBar(content: Text("Id is $userName")));
2021-04-10 19:48:24 +00:00
},
),
2021-04-10 19:01:03 +00:00
),
2021-04-10 18:45:44 +00:00
);
}
2021-04-10 19:48:24 +00:00
void showSnackbar(dynamic a) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(a.toString()),
));
}
2021-04-10 18:45:44 +00:00
}