@ -33,7 +33,7 @@ class Body extends StatefulWidget {
}
class _MyBodyState extends State < Body > {
final String userName = Random ( ) . nextInt ( 1000 ) . toString ( ) ;
final String userName = Random ( ) . nextInt ( 1000 0 ) . toString ( ) ;
final Strategy strategy = Strategy . P2P_STAR ;
String cId = " 0 " ; / / currently connected device ID
File tempFile ; / / stores the file being transferred
@ -42,14 +42,17 @@ class _MyBodyState extends State<Body> {
@ override
Widget build ( BuildContext context ) {
return Center (
child: Column (
child: Padding (
padding: const EdgeInsets . all ( 8.0 ) ,
child: ListView (
children: < Widget > [
Text ( " Permissions " , ) ,
Wrap (
children: < Widget > [
RaisedButton (
child: Text ( " check Permission" ) ,
child: Text ( " check Location Permission" ) ,
onPressed: ( ) async {
if ( await Nearby ( ) . check Permissions ( ) ) {
if ( await Nearby ( ) . check Location Permission( ) ) {
Scaffold . of ( context ) . showSnackBar ( SnackBar (
content: Text ( " Location permissions granted :) " ) ) ) ;
} else {
@ -59,13 +62,34 @@ class _MyBodyState extends State<Body> {
} ,
) ,
RaisedButton (
child: Text ( " askPermission " ) ,
child: Text ( " askLocationPermission " ) ,
onPressed: ( ) async {
await Nearby ( ) . askLocationPermission ( ) ;
} ,
) ,
RaisedButton (
child: Text ( " checkExternalStoragePermission " ) ,
onPressed: ( ) async {
if ( await Nearby ( ) . checkExternalStoragePermission ( ) ) {
Scaffold . of ( context ) . showSnackBar ( SnackBar (
content:
Text ( " External Storage permissions granted :) " ) ) ) ;
} else {
Scaffold . of ( context ) . showSnackBar ( SnackBar (
content: Text (
" External Storage permissions not granted :( " ) ) ) ;
}
} ,
) ,
RaisedButton (
child: Text ( " askExternalStoragePermission " ) ,
onPressed: ( ) async {
await Nearby ( ) . askPermission ( ) ;
await Nearby ( ) . ask ExternalStorage Permission( ) ;
} ,
) ,
] ,
) ,
Divider ( ) ,
Text ( " User Name: " + userName ) ,
Wrap (
children: < Widget > [
@ -83,7 +107,7 @@ class _MyBodyState extends State<Body> {
showSnackbar ( status ) ;
} ,
onDisconnected: ( id ) {
showSnackbar ( " Disconnected: " + id ) ;
showSnackbar ( " Disconnected: " + id ) ;
} ,
) ;
showSnackbar ( a ) ;
@ -169,6 +193,8 @@ class _MyBodyState extends State<Body> {
await Nearby ( ) . stopAllEndpoints ( ) ;
} ,
) ,
Divider ( ) ,
Text ( " Sending Data " , ) ,
RaisedButton (
child: Text ( " Send Random Bytes Payload " ) ,
onPressed: ( ) async {
@ -195,6 +221,7 @@ class _MyBodyState extends State<Body> {
) ,
] ,
) ,
) ,
) ;
}
@ -261,10 +288,8 @@ class _MyBodyState extends State<Body> {
showSnackbar ( endid + " : FAILED to transfer file " ) ;
} else if ( payloadTransferUpdate . status = =
PayloadStatus . SUCCESS ) {
print (
showSnackbar (
" success, total bytes = ${ payloadTransferUpdate . totalBytes } " ) ;
showSnackbar ( endid +
" : SUCCESS in file transfer (file is un-named in downloads) " ) ;
if ( map . containsKey ( payloadTransferUpdate . id ) ) {
/ / rename the file now