mirror of
https://github.com/hackku21/loc-chain-app.git
synced 2024-10-27 20:34:05 +00:00
added ID
This commit is contained in:
parent
9416b1188e
commit
2fc02c6272
@ -1,9 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:loc_chain_app/widgets/navbar.dart';
|
||||
import 'dart:math';
|
||||
|
||||
void main() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final id = prefs.getString('id') ?? '0';
|
||||
if (id == '0') {
|
||||
prefs.setString('id', Random().nextInt(10000).toString());
|
||||
}
|
||||
|
||||
runApp(App());
|
||||
}
|
||||
|
@ -5,8 +5,10 @@ import 'dart:typed_data';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:nearby_connections/nearby_connections.dart';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class BluetoothPage extends StatefulWidget {
|
||||
BluetoothPage({Key key, this.title}) : super(key: key);
|
||||
BluetoothPage({Key? key, required this.title}) : super(key: key);
|
||||
final String title;
|
||||
|
||||
@override
|
||||
@ -14,7 +16,7 @@ class BluetoothPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _BluetoothPageState extends State<BluetoothPage> {
|
||||
final String userName = Random().nextInt(10000).toString();
|
||||
final id = SharedPreferences.getInstance().then((s) => s.getString('id'));
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -22,7 +24,9 @@ class _BluetoothPageState extends State<BluetoothPage> {
|
||||
appBar: AppBar(
|
||||
title: Text(widget.title),
|
||||
),
|
||||
body: Center(),
|
||||
body: Center(
|
||||
child: Text('$id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user