generated from josiadmin/flutter-template-getx-provider
mod repository appwrite
This commit is contained in:
107
lib/models/tank_model.dart
Normal file
107
lib/models/tank_model.dart
Normal file
@@ -0,0 +1,107 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
class TankModel {
|
||||
final String documentId;
|
||||
final String userId;
|
||||
final String date;
|
||||
final String odometer;
|
||||
final String liters;
|
||||
final String pricePerLiter;
|
||||
final String location;
|
||||
final String totalPrice;
|
||||
TankModel({
|
||||
required this.documentId,
|
||||
required this.userId,
|
||||
required this.date,
|
||||
required this.odometer,
|
||||
required this.liters,
|
||||
required this.pricePerLiter,
|
||||
required this.location,
|
||||
required this.totalPrice,
|
||||
});
|
||||
|
||||
TankModel copyWith({
|
||||
String? documentId,
|
||||
String? userId,
|
||||
String? date,
|
||||
String? odometer,
|
||||
String? liters,
|
||||
String? pricePerLiter,
|
||||
String? location,
|
||||
String? totalPrice,
|
||||
}) {
|
||||
return TankModel(
|
||||
documentId: documentId ?? this.documentId,
|
||||
userId: userId ?? this.userId,
|
||||
date: date ?? this.date,
|
||||
odometer: odometer ?? this.odometer,
|
||||
liters: liters ?? this.liters,
|
||||
pricePerLiter: pricePerLiter ?? this.pricePerLiter,
|
||||
location: location ?? this.location,
|
||||
totalPrice: totalPrice ?? this.totalPrice,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return <String, dynamic>{
|
||||
'documentId': documentId,
|
||||
'userId': userId,
|
||||
'date': date,
|
||||
'odometer': odometer,
|
||||
'liters': liters,
|
||||
'pricePerLiter': pricePerLiter,
|
||||
'location': location,
|
||||
'totalPrice': totalPrice,
|
||||
};
|
||||
}
|
||||
|
||||
factory TankModel.fromMap(Map<String, dynamic> map) {
|
||||
return TankModel(
|
||||
documentId: map['documentId'] as String,
|
||||
userId: map['userId'] as String,
|
||||
date: map['date'] as String,
|
||||
odometer: map['odometer'] as String,
|
||||
liters: map['liters'] as String,
|
||||
pricePerLiter: map['pricePerLiter'] as String,
|
||||
location: map['location'] as String,
|
||||
totalPrice: map['totalPrice'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory TankModel.fromJson(String source) => TankModel.fromMap(json.decode(source) as Map<String, dynamic>);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TankModel(documentId: $documentId, userId: $userId, date: $date, odometer: $odometer, liters: $liters, pricePerLiter: $pricePerLiter, location: $location, totalPrice: $totalPrice)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(covariant TankModel other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return
|
||||
other.documentId == documentId &&
|
||||
other.userId == userId &&
|
||||
other.date == date &&
|
||||
other.odometer == odometer &&
|
||||
other.liters == liters &&
|
||||
other.pricePerLiter == pricePerLiter &&
|
||||
other.location == location &&
|
||||
other.totalPrice == totalPrice;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return documentId.hashCode ^
|
||||
userId.hashCode ^
|
||||
date.hashCode ^
|
||||
odometer.hashCode ^
|
||||
liters.hashCode ^
|
||||
pricePerLiter.hashCode ^
|
||||
location.hashCode ^
|
||||
totalPrice.hashCode;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ class AppWriteProvider {
|
||||
}
|
||||
|
||||
Future<models.Session> login(Map map) async {
|
||||
await logout();
|
||||
final response = await account!.createEmailPasswordSession(
|
||||
email: map['email'],
|
||||
password: map['password'],
|
||||
@@ -89,52 +90,52 @@ class AppWriteProvider {
|
||||
|
||||
// Tank Stop CRUD operations
|
||||
// Create, Update, Get, List Tank Stops
|
||||
// Future<models.Document> createTankStop(Map map) async {
|
||||
// final response = await database!.createDocument(
|
||||
// databaseId: kAppWriteDatabaseID,
|
||||
// collectionId: kAppWriteCollectionID,
|
||||
// documentId: ID.unique(),
|
||||
// data: map,
|
||||
// );
|
||||
// return response;
|
||||
// }
|
||||
Future<models.Document> createTankStop(Map map) async {
|
||||
final response = await database!.createDocument(
|
||||
databaseId: szDatabaseID,
|
||||
collectionId: szCollectionID,
|
||||
documentId: ID.unique(),
|
||||
data: map,
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
// Future<models.Document> updateTankStop(String documentId, Map map) async {
|
||||
// final response = await database!.updateDocument(
|
||||
// databaseId: kAppWriteDatabaseID,
|
||||
// collectionId: kAppWriteCollectionID,
|
||||
// documentId: documentId,
|
||||
// data: map,
|
||||
// );
|
||||
// return response;
|
||||
// }
|
||||
Future<models.Document> updateTankStop(String documentId, Map map) async {
|
||||
final response = await database!.updateDocument(
|
||||
databaseId: szDatabaseID,
|
||||
collectionId: szCollectionID,
|
||||
documentId: documentId,
|
||||
data: map,
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
// Future<models.Document> getTankStopById(String documentId) async {
|
||||
// final response = await database!.getDocument(
|
||||
// databaseId: kAppWriteDatabaseID,
|
||||
// collectionId: kAppWriteCollectionID,
|
||||
// documentId: documentId,
|
||||
// );
|
||||
// return response;
|
||||
// }
|
||||
Future<models.Document> getTankStopById(String documentId) async {
|
||||
final response = await database!.getDocument(
|
||||
databaseId: szDatabaseID,
|
||||
collectionId: szCollectionID,
|
||||
documentId: documentId,
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
// Future<models.DocumentList> listTankStops(String userId) async {
|
||||
// final response = await database!.listDocuments(
|
||||
// databaseId: kAppWriteDatabaseID,
|
||||
// collectionId: kAppWriteCollectionID,
|
||||
// queries: [Query.equal('userId', userId)],
|
||||
// );
|
||||
// return response;
|
||||
// }
|
||||
Future<models.DocumentList> listTankStops(String userId) async {
|
||||
final response = await database!.listDocuments(
|
||||
databaseId: szDatabaseID,
|
||||
collectionId: szCollectionID,
|
||||
queries: [Query.equal('userId', userId)],
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
// Future<models.Document> deleteTankStop(String documentId) async {
|
||||
// final response = await database!.deleteDocument(
|
||||
// databaseId: kAppWriteDatabaseID,
|
||||
// collectionId: kAppWriteCollectionID,
|
||||
// documentId: documentId,
|
||||
// );
|
||||
// return response;
|
||||
// }
|
||||
Future<models.Document> deleteTankStop(String documentId) async {
|
||||
final response = await database!.deleteDocument(
|
||||
databaseId: szDatabaseID,
|
||||
collectionId: szCollectionID,
|
||||
documentId: documentId,
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
// Future<models.Document> createTrackPoint(map) async {
|
||||
// final response = await database!.createDocument(
|
||||
|
||||
@@ -6,14 +6,10 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <desktop_webview_window/desktop_webview_window_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
#include <window_to_front/window_to_front_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) desktop_webview_window_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopWebviewWindowPlugin");
|
||||
desktop_webview_window_plugin_register_with_registrar(desktop_webview_window_registrar);
|
||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
desktop_webview_window
|
||||
url_launcher_linux
|
||||
window_to_front
|
||||
)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import desktop_webview_window
|
||||
import device_info_plus
|
||||
import flutter_web_auth_2
|
||||
import package_info_plus
|
||||
@@ -14,7 +13,6 @@ import url_launcher_macos
|
||||
import window_to_front
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
DesktopWebviewWindowPlugin.register(with: registry.registrar(forPlugin: "DesktopWebviewWindowPlugin"))
|
||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||
FlutterWebAuth2Plugin.register(with: registry.registrar(forPlugin: "FlutterWebAuth2Plugin"))
|
||||
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
||||
|
||||
40
pubspec.lock
40
pubspec.lock
@@ -5,10 +5,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: appwrite
|
||||
sha256: "2214b9f5f8227fd16b8e25539cee70a3df618be5b4a4c5602bcb1e5cde0f53e4"
|
||||
sha256: "0d354ab7c42f25b38ed6c54225a997573c0ecc70e83cfabbdd1161fd6dbea752"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "20.2.2"
|
||||
version: "16.1.0"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -73,22 +73,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.8"
|
||||
desktop_webview_window:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: desktop_webview_window
|
||||
sha256: "57cf20d81689d5cbb1adfd0017e96b669398a669d927906073b0e42fc64111c0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.3"
|
||||
device_info_plus:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: device_info_plus
|
||||
sha256: dd0e8e02186b2196c7848c9d394a5fd6e5b57a43a546082c5820b1ec72317e33
|
||||
sha256: a7fd703482b391a87d60b6061d04dfdeab07826b96f9abd8f5ed98068acc0074
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "12.2.0"
|
||||
version: "10.1.2"
|
||||
device_info_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -151,18 +143,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_web_auth_2
|
||||
sha256: "3c14babeaa066c371f3a743f204dd0d348b7d42ffa6fae7a9847a521aff33696"
|
||||
sha256: "4d3d2fd3d26bf1a26b3beafd4b4b899c0ffe10dc99af25abc58ffe24e991133c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.0"
|
||||
version: "3.1.2"
|
||||
flutter_web_auth_2_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_web_auth_2_platform_interface
|
||||
sha256: c63a472c8070998e4e422f6b34a17070e60782ac442107c70000dd1bed645f4d
|
||||
sha256: e8669e262005a8354389ba2971f0fc1c36188481234ff50d013aaf993f30f739
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.0"
|
||||
version: "3.1.0"
|
||||
flutter_web_plugins:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@@ -244,18 +236,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.16.0"
|
||||
version: "1.17.0"
|
||||
package_info_plus:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus
|
||||
sha256: f69da0d3189a4b4ceaeb1a3defb0f329b3b352517f52bed4290f83d4f06bc08d
|
||||
sha256: "16eee997588c60225bda0488b6dcfac69280a6b7a3cf02c741895dd370a02968"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.0.0"
|
||||
version: "8.3.1"
|
||||
package_info_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -385,10 +377,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
|
||||
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.6"
|
||||
version: "0.7.7"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -521,10 +513,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32_registry
|
||||
sha256: "6f1b564492d0147b330dd794fee8f512cec4977957f310f9951b5f9d83618dae"
|
||||
sha256: "21ec76dfc731550fd3e2ce7a33a9ea90b828fdf19a5c3bcf556fa992cfa99852"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "1.1.5"
|
||||
window_to_front:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -9,7 +9,7 @@ environment:
|
||||
sdk: ^3.9.2
|
||||
|
||||
dependencies:
|
||||
appwrite: ^20.2.2
|
||||
appwrite: ^16.0.0
|
||||
cupertino_icons: ^1.0.8
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
@@ -6,13 +6,10 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <desktop_webview_window/desktop_webview_window_plugin.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
#include <window_to_front/window_to_front_plugin.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
DesktopWebviewWindowPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("DesktopWebviewWindowPlugin"));
|
||||
UrlLauncherWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
|
||||
WindowToFrontPluginRegisterWithRegistrar(
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
desktop_webview_window
|
||||
url_launcher_windows
|
||||
window_to_front
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user