provokateurin / dart-nextcloud

A Nextcloud client for dart
Other
20 stars 15 forks source link

Unhandled Exception: type 'Null' is not a subtype of type 'String' in type cast #49

Closed atom83 closed 2 years ago

atom83 commented 3 years ago

Hi, Tried this simple example Future createFolder() async { try { final client = NextCloudClient.withCredentials( Uri(host: '---'), 'xxx', 'xxx', ); final files = await client.webDav.ls('/'); for (final file in files){ print(file.path); } } on RequestException catch (e, stacktrace) { print(e.statusCode); print(e.body); print(stacktrace); } }

but get error: Unhandled Exception: type 'Null' is not a subtype of type 'String' in type cast E/flutter (28814): #0 new UserData.fromJson (package:nextcloud/src/user/userdata.dart:15:38) E/flutter (28814): #1 UserClient.getUser (package:nextcloud/src/user/client.dart:21:21) E/flutter (28814): ......

I did everything correct right?

Thanks for help.

atom83 commented 3 years ago

sorry, found it already. My users in Nextcloud do not have an E-Mail Adress, and then in userdata.dart error happens at: json['ocs']['data']['email'] as String,

Added E-Mail address => works like a charm now. Thanks for this Lib

provokateurin commented 2 years ago

Fixed in https://github.com/jld3103/nextcloud-neon/tree/4f7c506c0134442706a8638cb7b10c62f2337b2a/packages/nextcloud/lib/src/clients/generated/provisioning_api