Skip to content

Commit c9fd040

Browse files
Add sample code (#60)
Fix docs warning on release
1 parent d87d2a4 commit c9fd040

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- To learn more about how to best use this new feature see our guide
1414
here: [Verify shift presence before starting work](https://developer.hypertrack.com/docs/clock-in-out-tagging#verify-shift-presence-before-starting-work)
1515

16+
```dart
17+
// check worker presence synchronously
18+
var activeOrders = await HyperTrack.orders;
19+
Order? currentOrder = activeOrders["current_order"];
20+
if (currentOrder != null) {
21+
handlePresence(currentOrder.isInsideGeofence);
22+
} else {
23+
print("'current_order' not found");
24+
}
25+
26+
// or subscribe to the changes in orders to get the status updates
27+
HyperTrack.ordersSubscription.listen((orders) {
28+
Order? currentOrder = orders["current_order"];
29+
if (currentOrder != null) {
30+
handlePresence(currentOrder.isInsideGeofence);
31+
} else {
32+
print("'current_order' not found");
33+
}
34+
});
35+
36+
// handle worker presence inside the order destination geofence
37+
void handlePresence(Result<bool, LocationError> isInsideGeofence) {
38+
switch (isInsideGeofence.runtimeType) {
39+
case Success:
40+
if ((isInsideGeofence as Success).value) {
41+
// allow worker to clock in for the shift
42+
} else {
43+
// "to clock in you must be at order destination"
44+
}
45+
break;
46+
case Failure:
47+
// resolve errors to check for presence
48+
break;
49+
}
50+
}
51+
```
52+
1653
### Changed
1754

1855
- Updated HyperTrack SDK iOS to [5.7.0](https://github.com/hypertrack/sdk-ios/releases/tag/5.7.0)

justfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,18 @@ release type="dry-run": setup
8787

8888
echo "Are you sure you want to publish version $VERSION? (y/N)"
8989
just _ask-confirm
90+
# removing docs to avoid doc/ folder warning
91+
rm -rf docs
9092
flutter pub publish
93+
@echo "Generating the docs back (removed to avoid doc/ folder warning)"
94+
just docs
9195
open https://pub.dev/packages/hypertrack_plugin/versions/$VERSION
9296
else
9397
# removing docs to avoid doc/ folder warning
9498
rm -rf docs
9599
echo "Dry run for version $VERSION"
96100
flutter pub publish --dry-run
101+
# generating the docs back
97102
just docs
98103
fi
99104

0 commit comments

Comments
 (0)