From 4d8a693119271aef74c68f1b5b4567be1baaca78 Mon Sep 17 00:00:00 2001 From: Phill Wiggins <phill.wiggins@gmail.com> Date: Fri, 31 May 2019 15:57:13 +0100 Subject: [PATCH] Revert "Support Relation. (#178)" This reverts commit 6ed26e16964f2c316427cde02936a650a76f4159. --- .gitignore | 2 - CHANGELOG.md | 2 - README.md | 17 +--- example/ios/Runner.xcodeproj/project.pbxproj | 2 - .../repositories/user/provider_db_user.dart | 4 +- example/lib/main.dart | 86 +++++++++---------- example/windows/find_vcvars.dart | 17 ++-- example/windows/generate_props.dart | 12 +-- lib/generated/i18n.dart | 19 ++-- lib/parse_server_sdk.dart | 22 ++--- lib/src/base/parse_constants.dart | 3 +- lib/src/data/core_store.dart | 14 +-- lib/src/data/core_store_impl.dart | 44 ++++------ lib/src/data/parse_core_data.dart | 42 +++------ lib/src/network/parse_live_query.dart | 21 ++--- lib/src/network/parse_query.dart | 17 ++-- lib/src/objects/parse_acl.dart | 9 +- lib/src/objects/parse_error.dart | 1 + lib/src/objects/parse_file.dart | 13 +-- lib/src/objects/parse_function.dart | 5 +- lib/src/objects/parse_geo_point.dart | 5 +- lib/src/objects/parse_installation.dart | 40 ++++----- lib/src/objects/parse_object.dart | 15 +--- lib/src/objects/parse_relation.dart | 44 ---------- .../response/parse_error_response.dart | 4 +- .../response/parse_exception_response.dart | 3 +- .../response/parse_response_builder.dart | 4 +- .../response/parse_response_utils.dart | 9 +- .../response/parse_success_no_results.dart | 3 +- lib/src/utils/parse_date_format.dart | 2 +- lib/src/utils/parse_decoder.dart | 4 +- lib/src/utils/parse_encoder.dart | 4 - lib/src/utils/parse_file_extensions.dart | 2 - lib/src/utils/parse_logger.dart | 15 ++-- lib/src/utils/parse_utils.dart | 8 +- pubspec.yaml | 3 +- 36 files changed, 190 insertions(+), 327 deletions(-) delete mode 100644 lib/src/objects/parse_relation.dart diff --git a/.gitignore b/.gitignore index c4f26e041..e8ac88703 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,3 @@ build/ .idea example/ios/Frameworks/ example/lib/ui/ - -.vscode/ diff --git a/CHANGELOG.md b/CHANGELOG.md index eef1ece34..37975d799 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,3 @@ -## 1.0.22 - ## 1.0.21 LiveQuery fix Logout fix diff --git a/README.md b/README.md index e199c25ae..7643287bf 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Want to get involved? Join our Slack channel and help out! (http://flutter-parse To install, either add to your pubspec.yaml ```yml dependencies: - parse_server_sdk: ^1.0.22 + parse_server_sdk: ^1.0.21 ``` or clone this repository and add to your project. As this is an early development with multiple contributors, it is probably best to download/clone and keep updating as an when a new feature is added. @@ -537,21 +537,6 @@ final Map<String, String> params = <String, String>{'plan': 'paid'}; function.execute(parameters: params); ``` -## Relation -The SDK supports Relation. - -To Retrive a relation instance for user, call: -```dart -final relation = user.getRelation('dietPlans'); -``` - -and then you can add a relation to the passed in object. - -```dart -relation.add(dietPlan); -final result = await user.save(); -``` - ## Other Features of this library Main: * Installation (View the example application) diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index ca2c16c33..d815bf063 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -44,11 +44,9 @@ 24DF2572E6AEEB9F7CE180C9 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; }; 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; }; - 5804EFBD11740E02FC51BC3E /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; }; - 96499D95196B10F296043703 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; }; 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; }; diff --git a/example/lib/data/repositories/user/provider_db_user.dart b/example/lib/data/repositories/user/provider_db_user.dart index a7e5380e9..d135418c8 100644 --- a/example/lib/data/repositories/user/provider_db_user.dart +++ b/example/lib/data/repositories/user/provider_db_user.dart @@ -79,7 +79,6 @@ class UserProviderDB implements UserProviderContract { Map<String, dynamic> convertItemToStorageMap(User item) { final Map<String, dynamic> values = Map<String, dynamic>(); - // ignore: invalid_use_of_protected_member values['value'] = json.jsonEncode(item.toJson(full: true)); values[keyVarObjectId] = item.objectId; item.updatedAt != null @@ -91,7 +90,8 @@ class UserProviderDB implements UserProviderContract { User convertRecordToItem({Record record, Map<String, dynamic> values}) { try { values ??= record.value; - final User item = User.clone().fromJson(json.jsonDecode(values['value'])); + final User item = + User.clone().fromJson(json.jsonDecode(values['value'])); return item; } catch (e) { return null; diff --git a/example/lib/main.dart b/example/lib/main.dart index d18963a20..3e26e8e18 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -10,6 +10,7 @@ import 'package:flutter_plugin_example/data/repositories/diet_plan/repository_di import 'package:flutter_plugin_example/data/repositories/user/repository_user.dart'; import 'package:flutter_plugin_example/domain/constants/application_constants.dart'; import 'package:flutter_plugin_example/domain/utils/db_utils.dart'; +import 'package:flutter_plugin_example/pages/decision_page.dart'; import 'package:flutter_stetho/flutter_stetho.dart'; import 'package:parse_server_sdk/parse_server_sdk.dart'; @@ -40,74 +41,69 @@ class MyApp extends StatefulWidget { class _MyAppState extends State<MyApp> { DietPlanRepository dietPlanRepo; UserRepository userRepo; - - String text = ''; - @override void initState() { super.initState(); - initData(); + // initData(); } @override Widget build(BuildContext context) { return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('Plugin example app'), - ), - body: Center( - child: Text(text), + debugShowCheckedModeBanner: false, + theme: ThemeData( + primarySwatch: Colors.blue, ), - ), - ); + title: 'Parse Server Example', + home: DecisionPage()); } Future<void> initData() async { // Initialize repository - await initRepository(); + // await initRepository(); // Initialize parse Parse().initialize(keyParseApplicationId, keyParseServerUrl, masterKey: keyParseMasterKey, debug: true); + //parse serve with secure store and desktop support + +// Parse().initialize(keyParseApplicationId, keyParseServerUrl, +// masterKey: keyParseMasterKey, +// debug: true, +// coreStore: CoreStoreImp.getInstance()); + // Check server is healthy and live - Debug is on in this instance so check logs for result final ParseResponse response = await Parse().healthCheck(); if (response.success) { await runTestQueries(); - text += 'runTestQueries\n'; + print('runTestQueries'); } else { - text += 'Server health check failed'; print('Server health check failed'); } } Future<void> runTestQueries() async { // Basic repository example - await repositoryAddUser(); - await repositoryAddItems(); - await repositoryGetAllItems(); + //await repositoryAddUser(); + //await repositoryAddItems(); + //await repositoryGetAllItems(); //Basic usage - await createItem(); - await getAllItems(); - await getAllItemsByName(); - await getSingleItem(); - await getConfigs(); - await query(); - await initUser(); - await initInstallation(); - await function(); - await functionWithParameters(); - await test(); - } - - Future<void> initInstallation() async { - final ParseInstallation installation = - await ParseInstallation.currentInstallation(); - final ParseResponse response = await installation.create(); - print(response); + // createItem(); + // getAllItems(); + // getAllItemsByName(); + // getSingleItem(); + // getConfigs(); + // query(); + // initUser(); +// var instalattion = await ParseInstallation.currentInstallation(); +// var rees = instalattion.create(); +// print(rees); + //function(); + //functionWithParameters(); + // test(); } Future<void> test() async { @@ -363,13 +359,13 @@ class _MyAppState extends State<MyApp> { dietPlanRepo ??= DietPlanRepository.init(await getDB()); userRepo ??= UserRepository.init(await getDB()); } -} -const String dietPlansToAdd = - '[{"className":"Diet_Plans","Name":"Textbook","Description":"For an active lifestyle and a straight forward macro plan, we suggest this plan.","Fat":25,"Carbs":50,"Protein":25,"Status":0},' - '{"className":"Diet_Plans","Name":"Body Builder","Description":"Default Body Builders Diet","Fat":20,"Carbs":40,"Protein":40,"Status":0},' - '{"className":"Diet_Plans","Name":"Zone Diet","Description":"Popular with CrossFit users. Zone Diet targets similar macros.","Fat":30,"Carbs":40,"Protein":30,"Status":0},' - '{"className":"Diet_Plans","Name":"Low Fat","Description":"Low fat diet.","Fat":15,"Carbs":60,"Protein":25,"Status":0},' - '{"className":"Diet_Plans","Name":"Low Carb","Description":"Low Carb diet, main focus on quality fats and protein.","Fat":35,"Carbs":25,"Protein":40,"Status":0},' - '{"className":"Diet_Plans","Name":"Paleo","Description":"Paleo diet.","Fat":60,"Carbs":25,"Protein":10,"Status":0},' - '{"className":"Diet_Plans","Name":"Ketogenic","Description":"High quality fats, low carbs.","Fat":65,"Carbs":5,"Protein":30,"Status":0}]'; + String dietPlansToAdd = + '[{"className":"Diet_Plans","Name":"Textbook","Description":"For an active lifestyle and a straight forward macro plan, we suggest this plan.","Fat":25,"Carbs":50,"Protein":25,"Status":0},' + '{"className":"Diet_Plans","Name":"Body Builder","Description":"Default Body Builders Diet","Fat":20,"Carbs":40,"Protein":40,"Status":0},' + '{"className":"Diet_Plans","Name":"Zone Diet","Description":"Popular with CrossFit users. Zone Diet targets similar macros.","Fat":30,"Carbs":40,"Protein":30,"Status":0},' + '{"className":"Diet_Plans","Name":"Low Fat","Description":"Low fat diet.","Fat":15,"Carbs":60,"Protein":25,"Status":0},' + '{"className":"Diet_Plans","Name":"Low Carb","Description":"Low Carb diet, main focus on quality fats and protein.","Fat":35,"Carbs":25,"Protein":40,"Status":0},' + '{"className":"Diet_Plans","Name":"Paleo","Description":"Paleo diet.","Fat":60,"Carbs":25,"Protein":10,"Status":0},' + '{"className":"Diet_Plans","Name":"Ketogenic","Description":"High quality fats, low carbs.","Fat":65,"Carbs":5,"Protein":30,"Status":0}]'; +} diff --git a/example/windows/find_vcvars.dart b/example/windows/find_vcvars.dart index bbbe33adb..375651e0a 100644 --- a/example/windows/find_vcvars.dart +++ b/example/windows/find_vcvars.dart @@ -17,15 +17,14 @@ import 'dart:io'; int main() { - final String programDir = Platform.environment['PROGRAMFILES(X86)']; - final String pathPrefix = '$programDir\\Microsoft Visual Studio'; - const String pathSuffix = 'VC\\Auxiliary\\Build\\vcvars64.bat'; - final List<String> years = <String>['2017', '2019']; - final List<String> flavors = <String>[ - 'Community', 'Professional', 'Enterprise', 'Preview']; - for (final String year in years) { - for (final String flavor in flavors) { - final String testPath = '$pathPrefix\\$year\\$flavor\\$pathSuffix'; + final programDir = Platform.environment['PROGRAMFILES(X86)']; + final pathPrefix = '$programDir\\Microsoft Visual Studio'; + const pathSuffix = 'VC\\Auxiliary\\Build\\vcvars64.bat'; + final years = ['2017', '2019']; + final flavors = ['Community', 'Professional', 'Enterprise', 'Preview']; + for (final year in years) { + for (final flavor in flavors) { + final testPath = '$pathPrefix\\$year\\$flavor\\$pathSuffix'; if (File(testPath).existsSync()) { print(testPath); return 0; diff --git a/example/windows/generate_props.dart b/example/windows/generate_props.dart index d895b0298..5a918942e 100644 --- a/example/windows/generate_props.dart +++ b/example/windows/generate_props.dart @@ -18,8 +18,8 @@ import 'dart:io'; void main(List<String> arguments) { - final String outputPath = arguments[0]; - final Map<String, String> settings = <String, String>{ + final outputPath = arguments[0]; + final settings = { 'FLUTTER_ROOT': arguments[1], 'EXTRA_BUNDLE_FLAGS': arguments[2], }; @@ -39,16 +39,16 @@ ${getItemGroupContent(settings)} } String getUserMacrosContent(Map<String, String> settings) { - final StringBuffer macroList = StringBuffer(); - for (final MapEntry<dynamic, dynamic> setting in settings.entries) { + final macroList = StringBuffer(); + for (final setting in settings.entries) { macroList.writeln(' <${setting.key}>${setting.value}</${setting.key}>'); } return macroList.toString(); } String getItemGroupContent(Map<String, String> settings) { - final StringBuffer macroList = StringBuffer(); - for (final String name in settings.keys) { + final macroList = StringBuffer(); + for (final name in settings.keys) { macroList.writeln(''' <BuildMacro Include="$name"> <Value>\$($name)</Value> <EnvironmentVariable>true</EnvironmentVariable> diff --git a/lib/generated/i18n.dart b/lib/generated/i18n.dart index 11205df28..db983ef03 100644 --- a/lib/generated/i18n.dart +++ b/lib/generated/i18n.dart @@ -1,3 +1,4 @@ + import 'dart:async'; import 'package:flutter/foundation.dart'; @@ -12,32 +13,35 @@ class S implements WidgetsLocalizations { const S(); static const GeneratedLocalizationsDelegate delegate = - GeneratedLocalizationsDelegate(); + const GeneratedLocalizationsDelegate(); static S of(BuildContext context) => Localizations.of<S>(context, WidgetsLocalizations); @override TextDirection get textDirection => TextDirection.ltr; + } class en extends S { const en(); } -class GeneratedLocalizationsDelegate - extends LocalizationsDelegate<WidgetsLocalizations> { + +class GeneratedLocalizationsDelegate extends LocalizationsDelegate<WidgetsLocalizations> { const GeneratedLocalizationsDelegate(); List<Locale> get supportedLocales { return const <Locale>[ - Locale("en", ""), + + const Locale("en", ""), + ]; } LocaleResolutionCallback resolution({Locale fallback}) { return (Locale locale, Iterable<Locale> supported) { - final Locale languageLocale = Locale(locale.languageCode, ""); + final Locale languageLocale = new Locale(locale.languageCode, ""); if (supported.contains(locale)) return locale; else if (supported.contains(languageLocale)) @@ -53,11 +57,12 @@ class GeneratedLocalizationsDelegate Future<WidgetsLocalizations> load(Locale locale) { final String lang = getLang(locale); switch (lang) { + case "en": - return SynchronousFuture<WidgetsLocalizations>(const en()); + return new SynchronousFuture<WidgetsLocalizations>(const en()); default: - return SynchronousFuture<WidgetsLocalizations>(const S()); + return new SynchronousFuture<WidgetsLocalizations>(const S()); } } diff --git a/lib/parse_server_sdk.dart b/lib/parse_server_sdk.dart index b52dbe5b5..865958e86 100644 --- a/lib/parse_server_sdk.dart +++ b/lib/parse_server_sdk.dart @@ -4,8 +4,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'dart:typed_data'; -import 'package:sembast/sembast.dart'; -import 'package:sembast/sembast_io.dart'; + import 'package:devicelocale/devicelocale.dart'; import 'package:http/http.dart'; import 'package:http/io_client.dart'; @@ -13,11 +12,13 @@ import 'package:meta/meta.dart'; import 'package:package_info/package_info.dart'; import 'package:path/path.dart' as path; import 'package:path_provider/path_provider.dart'; +import 'package:sembast/sembast.dart'; +import 'package:sembast/sembast_io.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:uuid/uuid.dart'; import 'package:web_socket_channel/io.dart'; import 'package:xxtea/xxtea.dart'; -part 'package:parse_server_sdk/src/objects/response/parse_response_utils.dart'; part 'package:parse_server_sdk/src/objects/response/parse_error_response.dart'; part 'package:parse_server_sdk/src/objects/response/parse_exception_response.dart'; part 'package:parse_server_sdk/src/objects/response/parse_response_builder.dart'; @@ -43,7 +44,6 @@ part 'src/objects/parse_function.dart'; part 'src/objects/parse_geo_point.dart'; part 'src/objects/parse_installation.dart'; part 'src/objects/parse_object.dart'; -part 'src/objects/parse_relation.dart'; part 'src/objects/parse_response.dart'; part 'src/objects/parse_session.dart'; part 'src/objects/parse_user.dart'; @@ -54,12 +54,6 @@ part 'src/utils/parse_file_extensions.dart'; part 'src/utils/parse_logger.dart'; part 'src/utils/parse_utils.dart'; -part 'src/utils/parse_date_format.dart'; - -part 'src/data/core_store.dart'; -part 'src/data/core_store_impl.dart'; -part 'src/data/xxtea_codec.dart'; - class Parse { ParseCoreData data; bool _hasBeenInitialized = false; @@ -85,7 +79,7 @@ class Parse { String sessionId, bool autoSendSessionId, SecurityContext securityContext, - CoreStore coreStore}) { + FutureOr<CoreStore> coreStore}) { final String url = removeTrailingSlash(serverUrl); ParseCoreData.init(appId, url, @@ -107,15 +101,14 @@ class Parse { bool hasParseBeenInitialized() => _hasBeenInitialized; Future<ParseResponse> healthCheck( - {bool debug, ParseHTTPClient client, bool sendSessionIdByDefault}) async { + {bool debug, ParseHTTPClient client, bool autoSendSessionId}) async { ParseResponse parseResponse; final bool _debug = isDebugEnabled(objectLevelDebug: debug); - final ParseHTTPClient _client = client ?? ParseHTTPClient( sendSessionId: - sendSessionIdByDefault ?? ParseCoreData().autoSendSessionId, + autoSendSessionId ?? ParseCoreData().autoSendSessionId, securityContext: ParseCoreData().securityContext); const String className = 'parseBase'; @@ -124,6 +117,7 @@ class Parse { try { final Response response = await _client.get('${ParseCoreData().serverUrl}$keyEndPointHealth'); + parseResponse = handleResponse<Parse>(null, response, type, _debug, className); } on Exception catch (e) { diff --git a/lib/src/base/parse_constants.dart b/lib/src/base/parse_constants.dart index 2f61a8c05..2bf12e226 100644 --- a/lib/src/base/parse_constants.dart +++ b/lib/src/base/parse_constants.dart @@ -1,7 +1,7 @@ part of flutter_parse_sdk; // Library -const String keySdkVersion = '1.0.22'; +const String keySdkVersion = '1.0.21'; const String keyLibraryName = 'Flutter Parse SDK'; // End Points @@ -36,7 +36,6 @@ const String keyClassSession = '_Session'; const String keyClassInstallation = '_Installation'; const String keyGeoPoint = 'GeoPoint'; const String keyFile = 'File'; -const String keyRelation = 'Relation'; // Headers const String keyHeaderSessionToken = 'X-Parse-Session-Token'; diff --git a/lib/src/data/core_store.dart b/lib/src/data/core_store.dart index b7d2fe450..13a1c6fd5 100644 --- a/lib/src/data/core_store.dart +++ b/lib/src/data/core_store.dart @@ -15,17 +15,17 @@ abstract class CoreStore { Future<List<String>> getStringList(String key); - Future<dynamic> setBool(String key, bool value); + Future setBool(String key, bool value); - Future<dynamic> setInt(String key, int value); + Future setInt(String key, int value); - Future<dynamic> setDouble(String key, double value); + Future setDouble(String key, double value); - Future<dynamic> setString(String key, String value); + Future setString(String key, String value); - Future<dynamic> setStringList(String key, List<String> values); + Future setStringList(String key, List<String> values); - Future<dynamic> remove(String key); + Future remove(String key); - Future<dynamic> clear(); + Future clear(); } diff --git a/lib/src/data/core_store_impl.dart b/lib/src/data/core_store_impl.dart index 8448ac8cd..3a65c7eb4 100644 --- a/lib/src/data/core_store_impl.dart +++ b/lib/src/data/core_store_impl.dart @@ -1,27 +1,20 @@ part of flutter_parse_sdk; class CoreStoreImp implements CoreStore { - CoreStoreImp._internal(this._store); - static CoreStoreImp _instance; - static Future<CoreStoreImp> getInstance( {DatabaseFactory factory, String password = 'flutter_sdk'}) async { - if (_instance == null) { factory ??= databaseFactoryIo; final SembastCodec codec = getXXTeaSembastCodec(password: password); String dbDirectory = ''; - - if (Platform.isIOS || Platform.isAndroid) { + if (Platform.isIOS || Platform.isAndroid) dbDirectory = (await getApplicationDocumentsDirectory()).path; - final String dbPath = path.join('$dbDirectory+/parse', 'parse.db'); - final Database db = await factory.openDatabase(dbPath, codec: codec); - _instance = CoreStoreImp._internal(db); - } + final String dbPath = path.join('$dbDirectory+/parse', 'parse.db'); + final Database db = await factory.openDatabase(dbPath, codec: codec); + _instance = CoreStoreImp._internal(db); } - return _instance; } @@ -38,67 +31,62 @@ class CoreStoreImp implements CoreStore { } @override - Future<String> get(String key) { + Future get(String key) { return _store.get(key); } @override Future<bool> getBool(String key) async { - final bool storedValue = await _store.get(key); - return storedValue; + return await _store.get(key) as bool; } @override Future<double> getDouble(String key) async { - final double storedValue = await _store.get(key); - return storedValue; + return await _store.get(key) as double; } @override Future<int> getInt(String key) async { - final int storedValue = await _store.get(key); - return storedValue; + return await _store.get(key) as int; } @override Future<String> getString(String key) async { - final String storedValue = await _store.get(key); - return storedValue; + return await _store.get(key) as String; } @override Future<List<String>> getStringList(String key) async { - final List<String> storedValue = await _store.get(key); - return storedValue; + return await _store.get(key) as List<String>; } @override - Future<dynamic> remove(String key) { + Future remove(String key) { return _store.delete(key); } @override - Future<dynamic> setBool(String key, bool value) { + Future setBool(String key, bool value) { return _store.put(value, key); } @override - Future<dynamic> setDouble(String key, double value) { + Future setDouble(String key, double value) { return _store.put(value, key); } @override - Future<dynamic> setInt(String key, int value) { + Future setInt(String key, int value) { return _store.put(value, key); } @override - Future<dynamic> setString(String key, String value) { + Future setString(String key, String value) { return _store.put(value, key); } @override - Future<dynamic> setStringList(String key, List<String> values) { + Future setStringList(String key, List<String> values) { return _store.put(values, key); } } diff --git a/lib/src/data/parse_core_data.dart b/lib/src/data/parse_core_data.dart index 7b84fb07d..b0e98593f 100644 --- a/lib/src/data/parse_core_data.dart +++ b/lib/src/data/parse_core_data.dart @@ -23,36 +23,20 @@ class ParseCoreData { String sessionId, bool autoSendSessionId, SecurityContext securityContext, - CoreStore store}) { + FutureOr<CoreStore> store}) { _instance = ParseCoreData._init(appId, serverUrl); - - _instance.storage ??= - store ?? CoreStoreImp.getInstance(password: masterKey); - - if (debug != null) { - _instance.debug = debug; - } - if (appName != null) { - _instance.appName = appName; - } - if (liveQueryUrl != null) { - _instance.liveQueryURL = liveQueryUrl; - } - if (clientKey != null) { - _instance.clientKey = clientKey; - } - if (masterKey != null) { - _instance.masterKey = masterKey; - } - if (sessionId != null) { - _instance.sessionId = sessionId; - } - if (autoSendSessionId != null) { + _instance.storage ??= store ?? + Future<CoreStore>.value( + SharedPreferencesCoreStore(SharedPreferences.getInstance())); + if (debug != null) _instance.debug = debug; + if (appName != null) _instance.appName = appName; + if (liveQueryUrl != null) _instance.liveQueryURL = liveQueryUrl; + if (clientKey != null) _instance.clientKey = clientKey; + if (masterKey != null) _instance.masterKey = masterKey; + if (sessionId != null) _instance.sessionId = sessionId; + if (autoSendSessionId != null) _instance.autoSendSessionId = autoSendSessionId; - } - if (securityContext != null) { - _instance.securityContext = securityContext; - } + if (securityContext != null) _instance.securityContext = securityContext; } String appName; @@ -65,7 +49,7 @@ class ParseCoreData { bool autoSendSessionId; SecurityContext securityContext; bool debug; - Future<CoreStore> storage; + FutureOr<CoreStore> storage; /// Sets the current sessionId. /// diff --git a/lib/src/network/parse_live_query.dart b/lib/src/network/parse_live_query.dart index 6dd0b3a76..066920f8b 100644 --- a/lib/src/network/parse_live_query.dart +++ b/lib/src/network/parse_live_query.dart @@ -22,9 +22,9 @@ class LiveQuery { Map<String, dynamic> _connectMessage; Map<String, dynamic> _subscribeMessage; Map<String, dynamic> _unsubscribeMessage; - Map<String, Function> eventCallbacks = <String, Function>{}; + Map<String, Function> eventCallbacks = {}; int _requestIdCount = 1; - final List<String> _liveQueryEvent = <String>[ + final List<String> _liveQueryEvent = [ 'create', 'enter', 'update', @@ -38,9 +38,7 @@ class LiveQuery { return _requestIdCount++; } - // ignore: always_specify_types - Future subscribe(QueryBuilder query) async { - + Future<void> subscribe(QueryBuilder query) async { String _liveQueryURL = _client.data.liveQueryURL; if (_liveQueryURL.contains('https')) { _liveQueryURL = _liveQueryURL.replaceAll('https', 'wss'); @@ -49,9 +47,8 @@ class LiveQuery { } final String _className = query.object.className; - query.limiters.clear(); //Remove limits in LiveQuery + query.limiters.clear(); //Remove limites in LiveQuery final String _where = query._buildQuery().replaceAll('where=', ''); - //Convert where condition to Map Map<String, dynamic> _whereMap = Map<String, dynamic>(); if (_where != '') { @@ -70,14 +67,14 @@ class LiveQuery { } else { if (_debug) { print('$_printConstLiveQuery: Error when connection client'); - return Future<void>.value(null); + return Future.value(null); } } _channel = IOWebSocketChannel(_webSocket); _channel.stream.listen((dynamic message) { if (_debug) { - print('$_printConstLiveQuery: Listen: $message'); + print('$_printConstLiveQuery: Listen: ${message}'); } final Map<String, dynamic> actionData = jsonDecode(message); @@ -106,7 +103,7 @@ class LiveQuery { print( '$_printConstLiveQuery: Error: ${error.runtimeType.toString()}'); } - return Future<ParseResponse>.value(handleException( + return Future.value(handleException( Exception(error), ParseApiRQ.liveQuery, _debug, _className)); }); @@ -131,7 +128,7 @@ class LiveQuery { _subscribeMessage = <String, dynamic>{ 'op': 'subscribe', 'requestId': requestId, - 'query': <String, dynamic>{ + 'query': { 'className': _className, 'where': _whereMap, } @@ -170,7 +167,7 @@ class LiveQuery { print( '$_printConstLiveQuery: UnsubscribeMessage: $_unsubscribeMessage'); } - _channel.sink.add(jsonEncode(_unsubscribeMessage)); + await _channel.sink.add(jsonEncode(_unsubscribeMessage)); await _channel.sink.close(); } } diff --git a/lib/src/network/parse_query.dart b/lib/src/network/parse_query.dart index f56bb47ea..d32a5c1ea 100644 --- a/lib/src/network/parse_query.dart +++ b/lib/src/network/parse_query.dart @@ -238,18 +238,16 @@ class QueryBuilder<T extends ParseObject> { } // Add a constraint to the query that requires a particular key's value match another QueryBuilder - // ignore: always_specify_types void whereMatchesQuery(String column, QueryBuilder query) { - final String inQuery = query._buildQueryRelational(query.object.className); + String inQuery = query._buildQueryRelational(query.object.className); queries.add(MapEntry<String, dynamic>( _SINGLE_QUERY, '\"$column\":{\"\$inQuery\":$inQuery}')); } //Add a constraint to the query that requires a particular key's value does not match another QueryBuilder - // ignore: always_specify_types void whereDoesNotMatchQuery(String column, QueryBuilder query) { - final String inQuery = query._buildQueryRelational(query.object.className); + String inQuery = query._buildQueryRelational(query.object.className); queries.add(MapEntry<String, dynamic>( _SINGLE_QUERY, '\"$column\":{\"\$notInQuery\":$inQuery}')); @@ -307,7 +305,8 @@ class QueryBuilder<T extends ParseObject> { if (item == queries.first) { queryBuilder += item; } else { - queryBuilder += ',$item'; + // ignore: prefer_single_quotes + queryBuilder += ",$item"; } } @@ -317,7 +316,7 @@ class QueryBuilder<T extends ParseObject> { /// Creates a query param using the column, the value and the queryOperator /// that the column and value are being queried against MapEntry<String, dynamic> _buildQueryWithColumnValueAndOperator( - MapEntry<String, dynamic> columnAndValue, String queryOperator) { + MapEntry columnAndValue, String queryOperator) { final String key = columnAndValue.key; final dynamic value = convertValueToCorrectType(parseEncode(columnAndValue.value)); @@ -371,10 +370,10 @@ class QueryBuilder<T extends ParseObject> { // Compact all the queries in the correct format for (MapEntry<String, dynamic> queryToCompact in listOfQueriesCompact) { - String queryToCompactValue = queryToCompact.value.toString(); - queryToCompactValue = queryToCompactValue.replaceFirst('{', ''); + var queryToCompactValue = queryToCompact.value.toString(); + queryToCompactValue = queryToCompactValue.replaceFirst("{", ""); queryToCompactValue = queryToCompactValue.replaceRange( - queryToCompactValue.length - 1, queryToCompactValue.length, ''); + queryToCompactValue.length - 1, queryToCompactValue.length, ""); if (listOfQueriesCompact.first == queryToCompact) { queryEnd += queryToCompactValue.replaceAll(queryStart, ' '); } else { diff --git a/lib/src/objects/parse_acl.dart b/lib/src/objects/parse_acl.dart index 7919343ab..2d3ff2e5e 100644 --- a/lib/src/objects/parse_acl.dart +++ b/lib/src/objects/parse_acl.dart @@ -1,7 +1,7 @@ part of flutter_parse_sdk; /// [ParseACL] is used to control which users can access or modify a particular object -/// [ParseObject] can have its own [ParseACL] +/// [ParseObject] can have its own [ParceACL] /// You can grant read and write permissions separately to specific users /// or you can grant permissions to "the public" so that, for example, any user could read a particular object but /// only a particular set of users could write to that object @@ -16,8 +16,7 @@ class ParseACL { } final String _publicKEY = '*'; - final Map<String, _ACLPermissions> _permissionsById = - <String, _ACLPermissions>{}; + final Map<String, _ACLPermissions> _permissionsById = {}; /// Helper for setting stuff void _setPermissionsIfNonEmpty( @@ -126,8 +125,8 @@ class _ACLPermissions { _ACLPermissions(this._readPermission, this._writePermission); final String _keyReadPermission = 'read'; final String _keyWritePermission = 'write'; - final bool _readPermission; - final bool _writePermission; + bool _readPermission = false; + bool _writePermission = false; bool getReadPermission() { return _readPermission; diff --git a/lib/src/objects/parse_error.dart b/lib/src/objects/parse_error.dart index 39fd9ad19..eda1e30b9 100644 --- a/lib/src/objects/parse_error.dart +++ b/lib/src/objects/parse_error.dart @@ -2,6 +2,7 @@ part of flutter_parse_sdk; /// ParseException is used in [ParseResult] to inform the user of the exception class ParseError { + ParseError( {this.code = -1, this.message = 'Unknown error', diff --git a/lib/src/objects/parse_file.dart b/lib/src/objects/parse_file.dart index ee93e3f40..bd2a53909 100644 --- a/lib/src/objects/parse_file.dart +++ b/lib/src/objects/parse_file.dart @@ -93,16 +93,9 @@ class ParseFile extends ParseObject { Future<ParseResponse> upload() async { if (saved) { //Creates a Fake Response to return the correct result - final Map<String, String> response = <String, String>{ - 'url': url, - 'name': name - }; - return handleResponse<ParseFile>( - this, - Response(json.encode(response), 201), - ParseApiRQ.upload, - _debug, - className); + final Map<String, String> response = <String, String>{'url': url, 'name': name}; + return handleResponse<ParseFile>(this, Response(json.encode(response), 201), + ParseApiRQ.upload, _debug, className); } final String ext = path.extension(file.path).replaceAll('.', ''); diff --git a/lib/src/objects/parse_function.dart b/lib/src/objects/parse_function.dart index 8f80d6a3d..16bcf12e6 100644 --- a/lib/src/objects/parse_function.dart +++ b/lib/src/objects/parse_function.dart @@ -34,9 +34,8 @@ class ParseCloudFunction extends ParseObject { } final Response result = - await _client.post(uri, body: json.encode(getObjectData())); - return handleResponse<ParseCloudFunction>( - this, result, ParseApiRQ.execute, _debug, className); + await _client.post(uri, body: json.encode(getObjectData())); + return handleResponse<ParseCloudFunction>(this, result, ParseApiRQ.execute, _debug, className); } /// Executes a cloud function that returns a ParseObject type diff --git a/lib/src/objects/parse_geo_point.dart b/lib/src/objects/parse_geo_point.dart index 61c52e894..f6c16168b 100644 --- a/lib/src/objects/parse_geo_point.dart +++ b/lib/src/objects/parse_geo_point.dart @@ -4,6 +4,7 @@ const String keyLatitude = 'latitude'; const String keyLongitude = 'longitude'; class ParseGeoPoint extends ParseObject { + /// Creates a Parse Object of type GeoPoint ParseGeoPoint( {double latitude = 0.0, @@ -12,6 +13,7 @@ class ParseGeoPoint extends ParseObject { ParseHTTPClient client, bool autoSendSessionId}) : super(keyGeoPoint) { + this.latitude = latitude; this.longitude = longitude; @@ -30,8 +32,7 @@ class ParseGeoPoint extends ParseObject { set longitude(double longitude) => set<double>(keyLongitude, longitude); @override - Map<String, dynamic> toJson({bool full = false, bool forApiRQ = false}) => - <String, dynamic>{ + Map<String, dynamic> toJson({bool full = false, bool forApiRQ = false}) => <String, dynamic>{ '__type': 'GeoPoint', 'latitude': latitude, 'longitude': longitude diff --git a/lib/src/objects/parse_installation.dart b/lib/src/objects/parse_installation.dart index a0ea8350b..008ed79f6 100644 --- a/lib/src/objects/parse_installation.dart +++ b/lib/src/objects/parse_installation.dart @@ -16,17 +16,14 @@ class ParseInstallation extends ParseObject { ParseInstallation.forQuery() : super(keyClassUser); static final List<String> readOnlyKeys = <String>[ - keyDeviceToken, - keyDeviceType, - keyInstallationId, - keyAppName, - keyAppVersion, - keyAppIdentifier, - keyParseVersion + // TODO + keyDeviceToken, keyDeviceType, keyInstallationId, + keyAppName, keyAppVersion, keyAppIdentifier, keyParseVersion ]; static String _currentInstallationId; //Getters/setters + Map<String, dynamic> get acl => super.get<Map<String, dynamic>>(keyVarAcl); set acl(Map<String, dynamic> acl) => @@ -68,17 +65,15 @@ class ParseInstallation extends ParseObject { /// Updates the installation with current device data Future<void> _updateInstallation() async { //Device type - if (Platform.isAndroid) { + if (Platform.isAndroid) set<String>(keyDeviceType, 'android'); - } else if (Platform.isIOS) { + else if (Platform.isIOS) set<String>(keyDeviceType, 'ios'); - } else if (Platform.isLinux) { + else if (Platform.isLinux) set<String>(keyDeviceType, 'Linux'); - } else if (Platform.isMacOS) { + else if (Platform.isMacOS) set<String>(keyDeviceType, 'MacOS'); - } else if (Platform.isWindows) { - set<String>(keyDeviceType, 'Windows'); - } + else if (Platform.isWindows) set<String>(keyDeviceType, 'Windows'); //Locale final String locale = await Devicelocale.currentLocale; @@ -87,6 +82,7 @@ class ParseInstallation extends ParseObject { } //Timezone + //TODO set<String>(keyTimeZone, ); //App info final PackageInfo packageInfo = await PackageInfo.fromPlatform(); @@ -99,10 +95,8 @@ class ParseInstallation extends ParseObject { @override Future<ParseResponse> create() async { final bool isCurrent = await ParseInstallation.isCurrent(this); - if (isCurrent) { - await _updateInstallation(); - } - + if (isCurrent) await _updateInstallation(); + //ParseResponse parseResponse = await super.create(); final ParseResponse parseResponse = await _create(); if (parseResponse.success && isCurrent) { saveInStorage(keyParseStoreInstallation); @@ -149,7 +143,6 @@ class ParseInstallation extends ParseObject { /// so it creates and sets the static current installation UUID static Future<ParseInstallation> _createInstallation() async { _currentInstallationId ??= Uuid().v4(); - final ParseInstallation installation = ParseInstallation(); installation._installationId = _currentInstallationId; await installation._updateInstallation(); @@ -206,15 +199,13 @@ class ParseInstallation extends ParseObject { ///Subscribes the device to a channel of push notifications. void subscribeToChannel(String value) { final List<dynamic> channel = <String>[value]; - setAddUnique('channels', channel); - save(); + addUnique('channels', channel); } ///Unsubscribes the device to a channel of push notifications. void unsubscribeFromChannel(String value) { final List<dynamic> channel = <String>[value]; - setRemove('channels', channel); - save(); + removeAll('channels', channel); } ///Returns an <List<String>> containing all the channel names this device is subscribed to. @@ -225,8 +216,7 @@ class ParseInstallation extends ParseObject { if (apiResponse.success) { final ParseObject installation = apiResponse.result; - return Future<List<dynamic>>.value( - installation.get<List<dynamic>>('channels')); + return Future.value(installation.get<List<dynamic>>('channels')); } else { return null; } diff --git a/lib/src/objects/parse_object.dart b/lib/src/objects/parse_object.dart index 404e28643..6b474fb9a 100644 --- a/lib/src/objects/parse_object.dart +++ b/lib/src/objects/parse_object.dart @@ -74,7 +74,7 @@ class ParseObject extends ParseBase implements ParseCloneable { final Map<String, dynamic> map = json.decode(result.body); objectId = map['objectId'].toString(); } - + return handleResponse<ParseObject>( this, result, ParseApiRQ.create, _debug, className); } on Exception catch (e) { @@ -99,11 +99,6 @@ class ParseObject extends ParseBase implements ParseCloneable { } } - /// Get the instance of ParseRelation class associated with the given key. - ParseRelation getRelation(String key) { - return ParseRelation(parent: this, key: key); - } - /// Removes an element from an Array @Deprecated('Prefer to use the setRemove() method in save()') Future<ParseResponse> remove(String key, dynamic values) async { @@ -179,14 +174,6 @@ class ParseObject extends ParseBase implements ParseCloneable { _arrayOperation('Add', key, values); } - void addRelation(String key, List<dynamic> values) { - _arrayOperation('AddRelation', key, values); - } - - void removeRelation(String key, List<dynamic> values) { - _arrayOperation('RemoveRelation', key, values); - } - /// Can be used to add arrays to a given type Future<ParseResponse> _sortArrays(ParseApiRQ apiRQType, String arrayAction, String key, List<dynamic> values) async { diff --git a/lib/src/objects/parse_relation.dart b/lib/src/objects/parse_relation.dart deleted file mode 100644 index bd8ca8b95..000000000 --- a/lib/src/objects/parse_relation.dart +++ /dev/null @@ -1,44 +0,0 @@ -part of flutter_parse_sdk; - -class ParseRelation<T extends ParseObject> { - ParseRelation({ParseObject parent, String key}) { - _parent = parent; - _key = key; - } - - String _targetClass; - ParseObject _parent; - String _key; - Set<T> _objects = Set<T>(); - - QueryBuilder getQuery() { - return QueryBuilder(ParseObject(_targetClass)); - } - - void add(T object) { - if (object != null) { - _targetClass = object.getClassName(); - _objects.add(object); - _parent.addRelation(_key, _objects.map((T value) { - return value.toPointer(); - }).toList()); - } - } - - void remove(T object) { - if (object != null) { - _targetClass = object.getClassName(); - _objects.remove(object); - _parent.removeRelation(_key, _objects.map((T value) { - return value.toPointer(); - }).toList()); - } - } - - Map<String, dynamic> toJson() => - <String, String>{'__type': keyRelation, 'className': _objects?.first?.className, 'objects': parseEncode(_objects?.toList())}; - - ParseRelation<T> fromJson(Map<String, dynamic> map) => ParseRelation<T>() - .._objects = parseDecode(map['objects']) - .._targetClass = map['className']; -} \ No newline at end of file diff --git a/lib/src/objects/response/parse_error_response.dart b/lib/src/objects/response/parse_error_response.dart index f7a50a623..b90196166 100644 --- a/lib/src/objects/response/parse_error_response.dart +++ b/lib/src/objects/response/parse_error_response.dart @@ -2,13 +2,13 @@ part of flutter_parse_sdk; /// Handles any errors returned in response ParseResponse buildErrorResponse(ParseResponse response, Response apiResponse) { + if (apiResponse.body == null) { return null; } final Map<String, dynamic> responseData = json.decode(apiResponse.body); - response.error = ParseError( - code: responseData[keyCode], message: responseData[keyError].toString()); + response.error = ParseError(code: responseData[keyCode], message: responseData[keyError].toString()); response.statusCode = responseData[keyCode]; return response; } diff --git a/lib/src/objects/response/parse_exception_response.dart b/lib/src/objects/response/parse_exception_response.dart index 9a798c8b0..e8b3f4367 100644 --- a/lib/src/objects/response/parse_exception_response.dart +++ b/lib/src/objects/response/parse_exception_response.dart @@ -3,7 +3,6 @@ part of flutter_parse_sdk; /// Handles exception instead of throwing an exception ParseResponse buildParseResponseWithException(Exception exception) { final ParseResponse response = ParseResponse(); - response.error = - ParseError(message: exception.toString(), isTypeOfException: true); + response.error = ParseError(message: exception.toString(), isTypeOfException: true); return response; } diff --git a/lib/src/objects/response/parse_response_builder.dart b/lib/src/objects/response/parse_response_builder.dart index a28e51c01..76b77d6c8 100644 --- a/lib/src/objects/response/parse_response_builder.dart +++ b/lib/src/objects/response/parse_response_builder.dart @@ -75,7 +75,7 @@ class _ParseResponseBuilder { response.result = items; response.count = items.length; } else if (map != null && map.length == 2 && map.containsKey('count')) { - final List<int> results = <int>[map['count']]; + final List<int> results = [map['count']]; response.results = results; response.result = results; response.count = map['count']; @@ -113,6 +113,6 @@ class _ParseResponseBuilder { } bool isHealthCheck(Response apiResponse) { - return apiResponse.body == '{\"status\":\"ok\"}'; + return apiResponse.body == "{\"status\":\"ok\"}"; } } diff --git a/lib/src/objects/response/parse_response_utils.dart b/lib/src/objects/response/parse_response_utils.dart index 12a96bc06..0fff98d21 100644 --- a/lib/src/objects/response/parse_response_utils.dart +++ b/lib/src/objects/response/parse_response_utils.dart @@ -4,8 +4,10 @@ part of flutter_parse_sdk; @protected ParseResponse handleResponse<T>(ParseCloneable object, Response response, ParseApiRQ type, bool debug, String className) { + final ParseResponse parseResponse = _ParseResponseBuilder().handleResponse<T>( - object, response, + object, + response, returnAsResult: shouldReturnAsABaseResult(type)); if (debug) { @@ -19,6 +21,7 @@ ParseResponse handleResponse<T>(ParseCloneable object, Response response, @protected ParseResponse handleException( Exception exception, ParseApiRQ type, bool debug, String className) { + final ParseResponse parseResponse = buildParseResponseWithException(exception); @@ -47,8 +50,7 @@ bool shouldReturnAsABaseResult(ParseApiRQ type) { } } -bool isUnsuccessfulResponse(Response apiResponse) => - apiResponse.statusCode != 200 && apiResponse.statusCode != 201; +bool isUnsuccessfulResponse(Response apiResponse) => apiResponse.statusCode != 200 && apiResponse.statusCode != 201; bool isSuccessButNoResults(Response apiResponse) { final Map<String, dynamic> decodedResponse = jsonDecode(apiResponse.body); @@ -60,3 +62,4 @@ bool isSuccessButNoResults(Response apiResponse) { return results.isEmpty; } + diff --git a/lib/src/objects/response/parse_success_no_results.dart b/lib/src/objects/response/parse_success_no_results.dart index e49eb989a..053dbadb4 100644 --- a/lib/src/objects/response/parse_success_no_results.dart +++ b/lib/src/objects/response/parse_success_no_results.dart @@ -1,8 +1,7 @@ part of flutter_parse_sdk; /// Handles successful responses with no results -ParseResponse buildSuccessResponseWithNoResults(ParseResponse response, - int code, String value) { +ParseResponse buildSuccessResponseWithNoResults(ParseResponse response, int code, String value) { response.success = true; response.statusCode = 200; response.error = ParseError(code: code, message: value); diff --git a/lib/src/utils/parse_date_format.dart b/lib/src/utils/parse_date_format.dart index c025878d7..fc394d734 100644 --- a/lib/src/utils/parse_date_format.dart +++ b/lib/src/utils/parse_date_format.dart @@ -63,4 +63,4 @@ class _ParseDateFormat { } return '0$n'; } -} +} \ No newline at end of file diff --git a/lib/src/utils/parse_decoder.dart b/lib/src/utils/parse_decoder.dart index 2ae0a4333..cff6fcb87 100644 --- a/lib/src/utils/parse_decoder.dart +++ b/lib/src/utils/parse_decoder.dart @@ -53,7 +53,7 @@ dynamic parseDecode(dynamic value) { switch (map['__type']) { case 'Date': final String iso = map['iso']; - return _parseDateFormat.parse(iso); + return _parseDateFormat.parse(iso); case 'Bytes': final String val = map['base64']; return base64.decode(val); @@ -77,8 +77,6 @@ dynamic parseDecode(dynamic value) { final num longitude = map['longitude'] ?? 0.0; return ParseGeoPoint( latitude: latitude.toDouble(), longitude: longitude.toDouble()); - case 'Relation': - return ParseRelation().fromJson(map); } } diff --git a/lib/src/utils/parse_encoder.dart b/lib/src/utils/parse_encoder.dart index 322d83b2c..f2929c376 100644 --- a/lib/src/utils/parse_encoder.dart +++ b/lib/src/utils/parse_encoder.dart @@ -34,10 +34,6 @@ dynamic parseEncode(dynamic value, {bool full}) { return value; } - if (value is ParseRelation) { - return value.toJson(); - } - if (value is ParseObject || value is ParseUser) { if (full) { return value.toJson(full: full); diff --git a/lib/src/utils/parse_file_extensions.dart b/lib/src/utils/parse_file_extensions.dart index 6482c2c41..7dc4a829a 100644 --- a/lib/src/utils/parse_file_extensions.dart +++ b/lib/src/utils/parse_file_extensions.dart @@ -1,7 +1,5 @@ part of flutter_parse_sdk; -// ignore_for_file: always_specify_types - /// Get the extension type of the file String getExtension(String contentType) { if (_extensions.containsKey(contentType) && diff --git a/lib/src/utils/parse_logger.dart b/lib/src/utils/parse_logger.dart index 50fce8190..047d3d37d 100644 --- a/lib/src/utils/parse_logger.dart +++ b/lib/src/utils/parse_logger.dart @@ -1,7 +1,10 @@ part of flutter_parse_sdk; -void logAPIResponse(String className, String type, +void logAPIResponse( + String className, + String type, ParseResponse parseResponse) { + const String spacer = ' \n'; String responseString = ''; @@ -63,10 +66,10 @@ void logRequest( if (name.isNotEmpty) { name = '$appName '; } - requestString += '----\n${name}API Request ($className : $type) :'; - requestString += '\nUri: $uri'; - requestString += '\nBody: $body'; + requestString += '----\n${name}API Request ($className : $type) :'; + requestString += '\nUri: $uri'; + requestString += '\nBody: $body'; - requestString += '\n----\n'; - print(requestString); + requestString += '\n----\n'; + print(requestString); } diff --git a/lib/src/utils/parse_utils.dart b/lib/src/utils/parse_utils.dart index 7ec88e4a5..c2d8a090f 100644 --- a/lib/src/utils/parse_utils.dart +++ b/lib/src/utils/parse_utils.dart @@ -15,7 +15,7 @@ dynamic convertValueToCorrectType(dynamic value) { /*if (value is String && !value.contains('__type')) { return '\"$value\"'; }*/ - + if (value is DateTime || value is ParseObject) { return parseEncode(value); } else { @@ -26,6 +26,7 @@ dynamic convertValueToCorrectType(dynamic value) { /// Sanitises a url Uri getSanitisedUri(ParseHTTPClient client, String pathToAppend, {Map<String, dynamic> queryParams, String query}) { + final Uri tempUri = Uri.parse(client.data.serverUrl); final Uri url = Uri( @@ -38,11 +39,10 @@ Uri getSanitisedUri(ParseHTTPClient client, String pathToAppend, return url; } - /// Removes unncessary / String removeTrailingSlash(String serverUrl) { - if (serverUrl.substring(serverUrl.length - 1) == '/') { - return serverUrl.substring(0, serverUrl.length - 1); + if (serverUrl.substring(serverUrl.length -1) == '/') { + return serverUrl.substring(0, serverUrl.length -1); } else { return serverUrl; } diff --git a/pubspec.yaml b/pubspec.yaml index 844f42d2a..48c9e1a9c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: parse_server_sdk description: Flutter plugin for Parse Server, (https://parseplatform.org), (https://back4app.com) -version: 1.0.22 +version: 1.0.21 homepage: https://github.com/phillwiggins/flutter_parse_sdk author: PhillWiggins <phill.wiggins@gmail.com> @@ -16,6 +16,7 @@ dependencies: http: ^0.12.0 #Database + shared_preferences: ^0.5.2 sembast: ^1.15.1 xxtea: ^2.0.2