Skip to content

Commit

Permalink
Add flutter_lints to core package, fix lints (#74)
Browse files Browse the repository at this point in the history
* Add flutter_lints to core package, fix lints

* nit
  • Loading branch information
mannprerak2 authored May 4, 2024
1 parent f1c6d24 commit 63104a9
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.1.1

- Fix lints.

## 4.1.0

- Min SDK bump 16 -> 19
Expand Down
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:flutter_lints/flutter.yaml
16 changes: 9 additions & 7 deletions lib/src/defs.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// contains enums and typedefs

// ignore_for_file: constant_identifier_names

import 'package:nearby_connections/src/classes.dart';

/// **P2P_CLUSTER** - best for small payloads and multiplayer games
Expand All @@ -20,19 +22,19 @@ enum PayloadType { NONE, BYTES, FILE, STREAM }
//
// Advertising lifecycle callbacks
//
typedef void OnConnectionInitiated(
typedef OnConnectionInitiated = void Function(
String endpointId, ConnectionInfo connectionInfo);
typedef void OnConnectionResult(String endpointId, Status status);
typedef void OnDisconnected(String endpointId);
typedef OnConnectionResult = void Function(String endpointId, Status status);
typedef OnDisconnected = void Function(String endpointId);

//
//
//
// Discovery lifecycle callbacks
//
typedef void OnEndpointFound(
typedef OnEndpointFound = void Function(
String endpointId, String endpointName, String serviceId);
typedef void OnEndpointLost(String? endpointId);
typedef OnEndpointLost = void Function(String? endpointId);

//
//
Expand All @@ -42,8 +44,8 @@ typedef void OnEndpointLost(String? endpointId);
/// For File, this marks the start of transfer
///
/// Uint8List bytes may be null, if [type] is not [PayloadType.BYTES]
typedef void OnPayloadReceived(String endpointId, Payload payload);
typedef OnPayloadReceived = void Function(String endpointId, Payload payload);

/// Called only once for Bytes and repeatedly for File until transfer is complete
typedef void OnPayloadTransferUpdate(
typedef OnPayloadTransferUpdate = void Function(
String endpointId, PayloadTransferUpdate payloadTransferUpdate);
27 changes: 12 additions & 15 deletions lib/src/nearby.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ class Nearby {
static Nearby? _instance;

factory Nearby() {
if (_instance == null) {
_instance = Nearby._();
}
_instance ??= Nearby._();
return _instance!;
}

Expand Down Expand Up @@ -145,8 +143,7 @@ class Nearby {
OnPayloadReceived? _onPayloadReceived;
OnPayloadTransferUpdate? _onPayloadTransferUpdate;

static const MethodChannel _channel =
const MethodChannel('nearby_connections');
static const MethodChannel _channel = MethodChannel('nearby_connections');

/// convenience method
///
Expand All @@ -170,9 +167,9 @@ class Nearby {
required OnDisconnected onDisconnected,
String serviceId = "com.pkmnapps.nearby_connections",
}) async {
this._advertConnectionInitiated = onConnectionInitiated;
this._advertConnectionResult = onConnectionResult;
this._advertDisconnected = onDisconnected;
_advertConnectionInitiated = onConnectionInitiated;
_advertConnectionResult = onConnectionResult;
_advertDisconnected = onDisconnected;

return await _channel.invokeMethod('startAdvertising', <String, dynamic>{
'userNickName': userNickName,
Expand Down Expand Up @@ -203,8 +200,8 @@ class Nearby {
required OnEndpointLost onEndpointLost,
String serviceId = "com.pkmnapps.nearby_connections",
}) async {
this._onEndpointFound = onEndpointFound;
this._onEndpointLost = onEndpointLost;
_onEndpointFound = onEndpointFound;
_onEndpointLost = onEndpointLost;

return await _channel.invokeMethod('startDiscovery', <String, dynamic>{
'userNickName': userNickName,
Expand Down Expand Up @@ -259,9 +256,9 @@ class Nearby {
required OnConnectionResult onConnectionResult,
required OnDisconnected onDisconnected,
}) async {
this._discoverConnectionInitiated = onConnectionInitiated;
this._discoverConnectionResult = onConnectionResult;
this._discoverDisconnected = onDisconnected;
_discoverConnectionInitiated = onConnectionInitiated;
_discoverConnectionResult = onConnectionResult;
_discoverDisconnected = onDisconnected;

return await _channel.invokeMethod(
'requestConnection',
Expand All @@ -286,8 +283,8 @@ class Nearby {
required OnPayloadReceived onPayLoadRecieved,
OnPayloadTransferUpdate? onPayloadTransferUpdate,
}) async {
this._onPayloadReceived = onPayLoadRecieved;
this._onPayloadTransferUpdate = onPayloadTransferUpdate;
_onPayloadReceived = onPayLoadRecieved;
_onPayloadTransferUpdate = onPayloadTransferUpdate;

return await _channel.invokeMethod(
'acceptConnection',
Expand Down
16 changes: 16 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -83,6 +91,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
lints:
dependency: transitive
description:
name: lints
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
version: "3.0.0"
matcher:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: nearby_connections
description: Plugin for the android NearbyConnections API. Bytes and Files Supported.
version: 4.1.0
version: 4.1.1
homepage: https://github.com/mannprerak2/nearby_connections

environment:
Expand All @@ -14,6 +14,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^3.0.0

flutter:
plugin:
Expand Down

0 comments on commit 63104a9

Please sign in to comment.