Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dart SDK not null safe #13

Closed
vinckr opened this issue Sep 14, 2021 · 29 comments
Closed

Dart SDK not null safe #13

vinckr opened this issue Sep 14, 2021 · 29 comments
Assignees

Comments

@vinckr
Copy link
Member

vinckr commented Sep 14, 2021

Report from amorevino developer:

Describe the bug

We have an SDK for Dart: https://pub.dev/packages/ory_client

This is created with Dart version 2.0. Dart support for null safety was added in 2.8 (https://dart.dev/null-safety).

This leads to errors when developing Flutter apps.

To Reproduce

https://pub.dev/packages/ory_client/score

Package is not null safe

Because:

    package:ory_client/api.dart where package:ory_client/api.dart is opting out from null safety.

Expected behavior

Package is null safe.

Additional context

I do not have experience using the package, so let me know if this is a trivial error or can be worked around easily.

@aeneasr
Copy link
Member

aeneasr commented Sep 14, 2021

Could you @ the dev here please?

@zepatrik
Copy link
Member

I assume @bennihz or @sashatalalasha?

@vinckr
Copy link
Member Author

vinckr commented Sep 15, 2021

Yes it was @sashatalalasha who reported the issue, sorry missed that.

@aeneasr
Copy link
Member

aeneasr commented Sep 15, 2021

@sashatalalasha have you been able to use the Dart SDK at all or does this prevent you from embedding it? Also, what version of the SDK have you been using?

Unfortunately the tool we use to generate the Dart code generates really bad code that sometimes doesn’t even compile. I have raised an issue in our pipeline on this (ory/sdk#109) and also opened/track several issues in openapi-generator:

I would suggest that when I am back next week we sit down together and try out the different options for Dart generation available and choose the least terrible one 😅

Alternatively we could also use the REST API in raw format for now. What do you think?

@sashatalalasha
Copy link

@aeneasr I can't build the app as it constantly throws errors. The SDK version is 2.13.4.

Actually, I didn't plan to use the ory client package as Benni is working on a backend that will serve as a mediator between the app and Kratos. Just wanted to check how direct communication works :)

Sure we can look for a good code generator together when you're back.

Thanks!

@aeneasr
Copy link
Member

aeneasr commented Sep 16, 2021

Ah ok! That works also :) If any of you both need help just drop an issue or GitHub discussion here!

It would also be great if we could sit together for an hour or so to look at your use of Dart and how we could get our SDKs up to speed as we have flows for native apps :)

@provokateurin
Copy link

ory/sdk#109 (comment) I want to fix this issue, as it would be great to have a correctly working dart generator.

@hpadrao
Copy link

hpadrao commented Feb 1, 2022

Any news?

@provokateurin
Copy link

I haven't tried using ory with a dart client in a while, but i've successfully used the dart2 generator from the openapi-generator 6.0.x branch. It has null-safety and seems to be working just fine. It is not released yet, so I don't know if ory wants to use it, but I'd say better use (maybe) unstable than outright broken code.

@aeneasr
Copy link
Member

aeneasr commented Feb 1, 2022

Oh nice! Yeah, 6.0x is still pretty broken I think but as soon as it becomes stable we wil definitely switch to it. Maybe we can also use individual versions for each SDK type, would require some refactoring though.

@aeneasr
Copy link
Member

aeneasr commented Feb 27, 2022

We have updated to the latest versions - not sure if that brings some improvements already?

@AllenKaplan
Copy link

AllenKaplan commented Jul 15, 2022

We have updated to the latest versions - not sure if that brings some improvements already?

FWIW still getting the following 5 months later :(

flutter run output
Running Gradle task 'assembleDebug'...
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/api.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/api_client.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/api_helper.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/api_exception.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/auth/authentication.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/auth/api_key_auth.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/auth/oauth.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/auth/http_basic_auth.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/auth/http_bearer_auth.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/api/metadata_api.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/api/v0alpha1_api.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/admin_create_identity_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/admin_create_self_service_recovery_link_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/admin_update_identity_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/authenticate_ok_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/container_change_response_item.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/container_create_created_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/container_top_ok_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/container_update_ok_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/container_wait_ok_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/container_wait_ok_body_error.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/error_response.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/generic_error.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/graph_driver_data.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/health_not_ready_status.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/health_status.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/id_response.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/identity.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/identity.dart:128:9: Error: Expected ',' before this.
        id: json[r'id'],
        ^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/identity_credentials.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/identity_state.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/image_delete_response_item.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/image_summary.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/inline_response200.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/inline_response2001.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/inline_response503.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/json_error.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/meta.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin_config.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin_config_args.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin_config_interface.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin_config_linux.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin_config_network.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin_config_rootfs.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin_config_user.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin_device.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin_env.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin_interface_type.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin_mount.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/plugin_settings.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/port.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/recovery_address.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/self_service_error.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/self_service_login_flow.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/self_service_logout_url.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/self_service_recovery_flow.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/self_service_recovery_flow_state.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/self_service_recovery_link.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/self_service_registration_flow.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/self_service_settings_flow.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/self_service_settings_flow_state.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/self_service_verification_flow.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/self_service_verification_flow_state.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/service_update_response.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/session.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/settings_profile_form_config.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_login_flow_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_login_flow_with_oidc_method_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_login_flow_with_password_method_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_logout_flow_without_browser_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_recovery_flow_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_recovery_flow_with_link_method_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_registration_flow_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_registration_flow_with_oidc_method_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_registration_flow_with_password_method_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_settings_flow_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_settings_flow_with_oidc_method_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_settings_flow_with_password_method_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_settings_flow_with_profile_method_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_verification_flow_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/submit_self_service_verification_flow_with_link_method_body.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/successful_self_service_login_without_browser.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/successful_self_service_registration_without_browser.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/successful_self_service_settings_without_browser.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/ui_container.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/ui_node.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/ui_node_anchor_attributes.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/ui_node_attributes.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/ui_node_image_attributes.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/ui_node_input_attributes.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/ui_node_text_attributes.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/ui_text.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/verifiable_identity_address.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/version.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/volume.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/volume.dart:116:9: Error: Expected ',' before this.
        usageData: VolumeUsageData.fromJson(json[r'UsageData']),
        ^^^^^^^^^
/C:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.3-alpha.8/lib/model/volume_usage_data.dart:4:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.0
^^^^^^^^^^^^


FAILURE: Build failed with an exception.

* Where:
Script 'C:\Program Files\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1156

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Program Files\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 45s
Exception: Gradle task assembleDebug failed with exit code 1

@aeneasr
Copy link
Member

aeneasr commented Jul 15, 2022

What version?

@provokateurin
Copy link

The 6.x.x version of the generator is now stable and should produce valid code (although not everything ory uses in the specs is supported).

@AllenKaplan
Copy link

What version?

@aeneasr

in my flutter project's pubspec.yaml ory_kratos_client: ^0.7.3-alpha.8, but I see the version available is ory_kratos_client: ^0.10.1 -- weird because I used flutter pub get ory_kratos_client and it didn't install latest

when I attempted to change manually I got

Running "flutter pub get" in ory_flutter...                     
Because ory_kratos_client >=0.7.5-alpha.2 depends on dio ^3.0.9 which depends on http_parser >=0.0.1 <4.0.0, ory_kratos_client >=0.7.5-alpha.2 requires http_parser >=0.0.1 <4.0.0.
And because http 0.13.4 depends on http_parser ^4.0.0 and no versions of http match >0.13.4 <0.14.0, ory_kratos_client >=0.7.5-alpha.2 is incompatible with http ^0.13.4.
So, because ory_flutter depends on both http ^0.13.4 and ory_kratos_client ^0.10.1, version solving failed.
pub get failed (1; So, because ory_flutter depends on both http ^0.13.4 and ory_kratos_client ^0.10.1, version solving failed.)

in my pubspec.yaml I also had http: ^0.13.4 which seemed to stop dio (pre req for openapi doc) and forced kratos api to a lower version that did not have null safety

I'm going to remove the http (in lieu of using dio which is a dep for openapi) and see how things go!

@AllenKaplan
Copy link

AllenKaplan commented Jul 15, 2022

Following up now that I am on ory_kratos_client: ^0.10.1

I still seem to have an error building
https://gist.github.com/b62c1cba39eecd6a51fdb5ae61417c49

flutter analyze output shows

allen@ALPHA MINGW64 /c/dev/ory_flutter
$ flutter analyze
Running "flutter pub get" in flutter_tools...                      21.4s
Analyzing ory_flutter...

   info - Avoid using private types in public APIs - lib\screens\sign_in.dart:13:3 - library_private_types_in_public_api
   info - The library 'package:ory_kratos_client/api.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:3:8 - import_of_legacy_library_into_null_safe
   info - The library 'package:ory_kratos_client/model/session.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:4:8 - import_of_legacy_library_into_null_safe
   info - The library 'package:ory_kratos_client/model/submit_self_service_login_flow_body.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:5:8 - import_of_legacy_library_into_null_safe
   info - The library 'package:ory_kratos_client/model/submit_self_service_logout_flow_without_browser_body.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:6:8 - import_of_legacy_library_into_null_safe
   info - The library 'package:ory_kratos_client/model/submit_self_service_registration_flow_body.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:7:8 - import_of_legacy_library_into_null_safe
   info - The library 'package:ory_kratos_client/model/successful_self_service_login_without_browser.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:8:8 - import_of_legacy_library_into_null_safe
   info - The library 'package:ory_kratos_client/model/successful_self_service_registration_without_browser.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:9:8 - import_of_legacy_library_into_null_safe
code snippet
import 'package:flutter/material.dart';
import 'package:ory_flutter/storage.dart';
import 'package:ory_kratos_client/api.dart';
import 'package:ory_kratos_client/model/session.dart';
import 'package:ory_kratos_client/model/submit_self_service_login_flow_body.dart';
import 'package:ory_kratos_client/model/submit_self_service_logout_flow_without_browser_body.dart';
import 'package:ory_kratos_client/model/submit_self_service_registration_flow_body.dart';
import 'package:ory_kratos_client/model/successful_self_service_login_without_browser.dart';
import 'package:ory_kratos_client/model/successful_self_service_registration_without_browser.dart';

class AuthService {
  final backendURL = const String.fromEnvironment('BACKEND');
  final kratosClient = OryKratosClient(
          basePathOverride: const String.fromEnvironment('KRATOS_API'))
      .getV0alpha2Api();

  Future<String> intiateRegistrationFlow() async {
    var response = await kratosClient
        .initializeSelfServiceRegistrationFlowWithoutBrowser();
    if (response.statusCode == 200) {
      return response.data.id; //return registration flow id
    } else if (response.statusCode == 400 || response.statusCode == 500) {
      throw Exception(response.statusMessage);
    } else {
      throw Exception();
    }
  }

  Future<String> initiateLoginFlow() async {
    var response =
        await kratosClient.initializeSelfServiceLoginFlowWithoutBrowser();
    if (response.statusCode == 200) {
      return response.data.id; //return login flow id
    } else if (response.statusCode == 400 || response.statusCode == 500) {
      throw Exception(response.statusMessage);
    } else {
      throw Exception();
    }
  }

  Future<SuccessfulSelfServiceLoginWithoutBrowser> signIn(
      String flowId, String email, String password) async {
    var body = SubmitSelfServiceLoginFlowBody((b) => b
      ..method = "password"
      ..password = password
      ..password_identifier = email);
    var response = await kratosClient.submitSelfServiceLoginFlow(flowId, body);

    if (response.statusCode == 200) {
      debugPrint('Signed in: ${response.data}', wrapWidth: 1024);
      return response.data;
    } else if (response.statusCode == 400 || response.statusCode == 500) {
      throw Exception(response.statusMessage);
    } else {
      throw Exception();
    }
  }

  Future<SuccessfulSelfServiceRegistrationWithoutBrowser> signUp(String flowId,
      String email, String password, String phone, String username) async {
    var body = SubmitSelfServiceRegistrationFlowBody((b) => b
      ..method = "password"
      ..password = password
      ..traits.email = email
      ..traits.phone = phone
      ..traits.username = username);
    var response =
        await kratosClient.submitSelfServiceRegistrationFlow(flowId, body);

    if (response.statusCode == 200) {
      debugPrint('Signed up: ${response.data}', wrapWidth: 1024);
      return response.data;
    } else if (response.statusCode == 400 || response.statusCode == 500) {
      throw Exception(response.statusMessage);
    } else {
      throw Exception();
    }
  }

  Future<Session> getCurrentSession(String token) async {
    var response = await kratosClient.toSession(xSessionToken: token);

    if (response.statusCode == 200) {
      debugPrint('Who am I: ${response.data}', wrapWidth: 1024);
      return response.data;
    } else if (response.statusCode == 400 || response.statusCode == 500) {
      throw Exception(response.statusMessage);
    } else {
      throw Exception();
    }
  }

  Future<void> signOut() async {
    final SecureStorage storage = SecureStorage();
    final String? sessionToken = await storage.getToken();
    if (sessionToken != null) {
      final body = SubmitSelfServiceLogoutFlowWithoutBrowserBody(
        (b) => b..session_token = sessionToken,
      );
      final response =
          await kratosClient.submitSelfServiceLogoutFlowWithoutBrowser(body);

      if (response.statusCode == 200) {
        debugPrint('Signed out: $response', wrapWidth: 1024);
        await storage.deleteToken();
        return response.data;
      } else if (response.statusCode == 400 || response.statusCode == 500) {
        throw Exception(response.statusMessage);
      } else {
        throw Exception();
      }
    }
  }
}

@AllenKaplan
Copy link

AllenKaplan commented Jul 15, 2022

Looking closer, all files are for dart 2.7 and pub.dev shows failing null safety

Taking a look at versioning it looks like there was some regression where previous versions had null safety -- weird since ory/sdk/scripts has dart with openapi generator v6.0.0 they actually still opt out of null safety :/

@AllenKaplan
Copy link

AllenKaplan commented Jul 15, 2022

Hey again @aeneasr!

So I think this might have to do with openapi generating using dart-dio over dart from this change ory/sdk@77fab25 -- this was much before flutter 3 release fwiw

regardless, I'm not sure if dart-dio was already updated for null safety or if dart-dio still requires this PR in openapi repo to be merged OpenAPITools/openapi-generator#12295 -- it does seem to be working with a user in the PR saying they have to use the PR's branch in production to get things working if you do want to use the branch

Regardless, it seems openapi gen v6.0.0 added support for dart null-safety here OpenAPITools/openapi-generator#10637

It would be great if the branched dart-dio or the non-dio dart generator can be used in a (pre)release on pub.dev -- at least until the PR is merged

This is a blocking issue for anyone using Flutter 3 (requires >= Dart 2.12 that added null safety) much appreciated 🙏

@aeneasr
Copy link
Member

aeneasr commented Jul 16, 2022

Got it, so shall we use the dart or dart2 generator?

@provokateurin
Copy link

provokateurin commented Jul 16, 2022

dart2, but you just set the generator to dart for that. idk it's weird, but that's how it works.

@aeneasr
Copy link
Member

aeneasr commented Jul 16, 2022

Ok nice, if anyone is up for the small change, PRs welcomed :)

@AllenKaplan
Copy link

@aeneasr PR here ory/sdk#202

@aeneasr
Copy link
Member

aeneasr commented Jul 17, 2022

Thank you - merged! A new release has also been triggered - let's see if it works now :)

@AllenKaplan
Copy link

@aeneasr not sure if the release should be live yet, but I'm not seeing it on pub.dev yet https://pub.dev/packages/ory_kratos_client/versions

image

@AllenKaplan
Copy link

AllenKaplan commented Jul 18, 2022

@AllenKaplan
Copy link

Current using the following in my pubspec.yaml until its on pub.dev

  ory_client:
    git:
      url: https://github.com/ory/sdk.git
      path: clients/client/dart

Ran into an OpenAPI issue for which I've opened an issue here OpenAPITools/openapi-generator#12914

Other than that the library is now working with null safety

@aeneasr
Copy link
Member

aeneasr commented Jul 20, 2022

Sorry for the late reply, please use the meta Ory SDK: https://pub.dev/packages/ory_client/versions

The Ory Kratos / Hydra / ... SDKs will only be released when we release a new tag for those. The Ory SDK is being regenerated everytime we make changes to console.ory.sh production!

@aeneasr
Copy link
Member

aeneasr commented Jul 21, 2022

The Dart SDK is now null safe! :) :)

Screenshot 2022-07-21 at 09 05 32

@aeneasr aeneasr closed this as completed Jul 21, 2022
@aeneasr aeneasr self-assigned this Jul 21, 2022
@provokateurin
Copy link

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants