Closed gd08xxx closed 11 months ago
CloudinaryContext.cloudinary = Cloudinary.fromCloudName This works, however it is deprecated
Hi @gd08xxx
Could you please share the code you're currently trying to use to upload the file to Cloudinary?
Are you following this step (https://cloudinary.com/documentation/flutter_quick_start#2_upload_an_image) as part of the Quick Start guide?
Here is an example:
//Create a basic Flutter app, and in main.dart copy and paste the following:
// Import the Cloudinary packages.
import 'package:cloudinary_url_gen/cloudinary.dart';
import 'package:cloudinary_flutter/image/cld_image.dart';
import 'package:cloudinary_flutter/cloudinary_context.dart';
import 'package:flutter/material.dart';
// Create a Cloudinary instance and set your cloud name.
void main() {
CloudinaryContext.cloudinary =
Cloudinary.fromCloudName(cloudName: "demo");
runApp(App());
}
Regards, Wissam
@wissam-khalili it is exactly the same as your example, but running with web. I guess the error 'Unsupported operation: Platform._version' triggers from web because web does not support this function.
I also found out that if use mobile safari and mobile chrome on my iOS 17 iPhone will not work due to the platform check regarding analytics, I believe they are related issues. The following work around works when initializing the sdk.
CloudinaryContext.cloudinary =
Cloudinary.fromCloudName(cloudName: cloudinaryCloudName);
if (kIsWeb) {
CloudinaryContext.cloudinary.config.urlConfig.analytics = false;
}
I built the web with web-renderer auto, which uses html for mobile and canvaskit for desktops.
Below are some stack traces I got from Sentry (similar to Google analytics)
I believe generateVersionString generates the error
Hi @gd08xxx Thank you for the report, we're currently working on a fix and will submit it as soon as its ready.
@adimiz1 thanks a lot for your prompt response
Closing the issue since the issue is fixed on version 1.2.0 Please reopen if you need further assistance
Unfortunately, I updated my cloudinary_flutter version to ^1.2.0 and cloudinary_url_gen to ^1.4.4 and it did not work. The following error came up with iOS mobile Safari.
cloudinary_flutter: ^1.2.0
cloudinary_url_gen: ^1.4.4
I used exactly your code to initialize my app
late CloudinaryObject cloudinary;
void main() {
cloudinary = CloudinaryObject.fromCloudName(cloudName: '<your_cloud_name>');
runApp(App());
}
and used cloudinary like this
final class Cloudinary extends CldImageWidget {
Cloudinary({super.key, required super.publicId, super.fit})
: super(transformation: defaultTransformation);
static Transformation defaultTransformation = Transformation()
/*
Removed Delivery.format(Format.auto) because it is not working on Safari
with release build
*/
..delivery(Delivery.quality(Quality.autoBest()));
}
or like this
CachedNetworkImageProvider(
(cloudinary.image(publicId)
..transformation(Cloudinary.defaultTransformation))
.toString(),
)
both did not work unfortunately and they all end up with the same error. Now desktop safari does not work as well (they all became grey boxes, there were images before)
I used flutter build web --release
I am not sure whether it affects the result or not
@adimiz1 sorry I am not a contributor and I am unable to reopen the issue. Should I start a new issue or continue with this thread? Thanks
Hi @gd08xxx Thank you for the report, we'll look into this
Hi @gd08xxx
When using CLDImageWidget
you'll need to pass it the Cloudinary object like this:
CldImageWidget(publicId: "<your_public_id>", cloudinary: cloudinary),
When CldImageWidget does not have a cloudinary object by default it tries to take it from an environment variable
We'll wrap and fix the issue for the web but in the meantime let me know if giving the widget the Cloudinary object helped
Thanks a lot, the workaround is working at the moment
Bug report for Cloudinary Flutter SDK
Before proceeding, please update to latest version and test if the issue persists
Describe the bug in a sentence or two.
CloudinaryObject.fromCloudName will generate 'Unsupported operation: Platform_version' error on Web …
Issue Type (Can be multiple)
[X] Build - Can’t install or import the SDK [ ] Performance - Performance issues [ ] Behaviour - Functions aren’t working as expected (Such as generate URL) [ ] Documentation - Inconsistency between the docs and behaviour [ ] Other (Specify)
Steps to reproduce
Start web with CloudinaryObject.fromCloudName
Error screenshots or Stack Trace (if applicable)
…
Build/Dependency management
[ ] Cocoa-Pods [ ] Carthage [ ] Manual import [ ] Other (Specify)
Is the issue reproducible only on a specific device?
[ ] No [x ] Yes, Chrome
Versions and Libraries (fill in the version numbers)
Flutter Cloudinary SDK version - cloudinary_flutter: ^1.1.0 OS (on the dev environment) - flutter: ^3.13.9 XCode/Android Studio - 0.0.0 Swift/Java/Kotlin - 0.0.0 Target iOS/Android - 0.0.0
Repository If possible, please provide a link to a reproducible repository that showcases the problem