Files
nearby_service/example/lib/components/peer_widget.dart
T
Ben Hagen abe519dae7 Add macOS support (#23)
* Add macOS support

* Update README

* Update to v0.2.0

* Document breaking changes

* Delete widget tests
2025-05-13 16:24:58 +02:00

39 lines
1.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:nearby_service/nearby_service.dart';
class PeerWidget extends StatelessWidget {
const PeerWidget({
super.key,
required this.device,
required this.isDarwinBrowser,
required this.onConnect,
required this.communicationChannelState,
});
final NearbyDevice device;
final bool isDarwinBrowser;
final ValueChanged<NearbyDevice> onConnect;
final CommunicationChannelState communicationChannelState;
@override
Widget build(BuildContext context) {
final connectedStateCaption = communicationChannelState.isLoading
? 'Wait for connection'
: 'Tap to chat';
final status =
device.status.isConnected ? connectedStateCaption : device.status.name;
final canTap = !communicationChannelState.isLoading;
return ListTile(
title: Text(
'${isDarwinBrowser ? 'Found device' : 'Pending invitation'} | ${device.info.displayName} | $status',
),
onTap: canTap ? () => onConnect(device) : null,
tileColor: Colors.blueAccent,
textColor: Colors.white,
);
}
}