Easy pocketbase tracker
This commit is contained in:
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"cmake.ignoreCMakeListsMissing": true
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pocketbase/pocketbase.dart'; // Import the PocketBase package
|
||||
import 'expectation_input_page.dart';
|
||||
// Import the edit clearance page
|
||||
import '../widgets/clearance_field.dart';
|
||||
|
||||
class FinalClearanceDisplay extends StatefulWidget {
|
||||
@@ -12,7 +12,8 @@ class FinalClearanceDisplay extends StatefulWidget {
|
||||
final bool isDarkMode;
|
||||
final Function toggleDarkMode;
|
||||
|
||||
const FinalClearanceDisplay({super.key,
|
||||
const FinalClearanceDisplay({
|
||||
super.key,
|
||||
required this.clearanceLimit,
|
||||
required this.route,
|
||||
required this.altitude,
|
||||
@@ -32,6 +33,7 @@ class FinalClearanceDisplayState extends State<FinalClearanceDisplay> {
|
||||
late String altitude;
|
||||
late String squawk;
|
||||
late String frequency;
|
||||
final PocketBase pb = PocketBase('http://backend.degnedict.de'); // Initialize PocketBase
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -41,9 +43,24 @@ class FinalClearanceDisplayState extends State<FinalClearanceDisplay> {
|
||||
altitude = widget.altitude;
|
||||
squawk = widget.squawk;
|
||||
frequency = widget.frequency;
|
||||
|
||||
_createPageViewRecord(); // Create a record with the current timestamp
|
||||
}
|
||||
|
||||
// Navigate to Edit Clearance Page and handle returned data
|
||||
// Function to create a new record with a timestamp in epoch milliseconds in your PocketBase collection
|
||||
Future<void> _createPageViewRecord() async {
|
||||
try {
|
||||
// Get the current time in epoch milliseconds
|
||||
int currentTimeInMillis = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
// Create a new record in the collection with the current epoch time
|
||||
await pb.collection('IFRbuddyUsage').create(body: {
|
||||
'timestamp': currentTimeInMillis, // Save current timestamp as epoch time (milliseconds)
|
||||
});
|
||||
} catch (e) {
|
||||
print('Error creating record: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// Navigate back to the first page (ExpectationInputPage)
|
||||
void _navigateHome(BuildContext context) {
|
||||
|
||||
@@ -288,6 +288,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.8"
|
||||
pocketbase:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: pocketbase
|
||||
sha256: "1d2958a3a7cb1e0050f425f179bd6557441fafcf740a79d5b8b80d6954149790"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.18.1"
|
||||
shared_preferences:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
@@ -37,6 +37,7 @@ dependencies:
|
||||
http: ^1.2.2
|
||||
shared_preferences: ^2.3.2
|
||||
flutter_launcher_icons: ^0.14.1
|
||||
pocketbase: ^0.18.1
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
Reference in New Issue
Block a user