dart_pad_widget icon indicating copy to clipboard operation
dart_pad_widget copied to clipboard

code parameter couldn't be applied to dartpad, Live demo is also broken.

Open burcugen opened this issue 1 year ago • 6 comments

Hello,

Dartpad widget didn't show the code that we passed as parameter, It shows the default code snippet. You can replicate the issue, by simply visiting the dart_pad live demo.

Dartpad now opened with the default code. void main() { for (int i = 0; i < 10; i++) { print('hello ${i + 1}'); } }

How can we fix this? Maybe the issue is related with this dartpad issue

Thanks in advance. Best, Burcu.

burcugen avatar Mar 11 '24 18:03 burcugen

Here is the most relevant info: https://github.com/dart-lang/dart-pad/wiki/Embedding-Guide#embedding-choices (i.e. the injection method I was using seems to be deprecated).

The new format is probably closer to what you linked: https://github.com/dart-lang/dart-pad/issues/2702. Here is the new documentation on the recommended way to inject: https://github.com/dart-lang/site-shared/tree/main/packages/inject_dartpad, and that is probably where I'd start . I'm not sure if it supports all of the varieties as before, but I'm happy to take a look at a PR if you want to give it a go. There really isn't much in this library since it is just a simple wrapper around a HTML platform view.

TimWhiting avatar Mar 11 '24 19:03 TimWhiting

I have the same issue to display and execute flutter code in the dartpad. Is it planed to update the widget ? It would be awesome !

fvisticot avatar Mar 12 '24 09:03 fvisticot

Fixed it by switching to an old dartpad url for now. The new embedding doesn't support all of the same options as before, and so it will take longer to figure out how best to evolve this package. Eventually I will migrate to the new embedding, since it should be much faster (doesn't use iframes).

TimWhiting avatar Mar 13 '24 21:03 TimWhiting

Hi @TimWhiting , Thanks for the update. Today, I want to update the library for my project for checking in. But I got the following error on the library file. Is there anything that I'm missing, I'm trying to run this for flutter 3.10.6. My current configuration as follows.

Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
../../../.pub-cache/hosted/pub.dev/dart_pad_widget-2.2.1/lib/dart_pad_widget.dart:145:8: Error: Undefined name 'platformViewRegistry'.
    ui.platformViewRegistry
       ^^^^^^^^^^^^^^^^^^^^
Failed to compile application.

My flutter config as follows:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.6, on macOS 14.3.1 23D60 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.89.0)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Screenshot 2024-05-05 at 9 15 05 PM

burcugen avatar May 05 '24 18:05 burcugen

Try pinning this package to the version 2.1.1 which will work on old versions of flutter if you cannot update your flutter sdk.

TimWhiting avatar May 05 '24 19:05 TimWhiting

Thanks for the help, I was able to run the 2.1.1 version with Flutter 3.19.0 sdk with success. 🚀🎉

burcugen avatar May 05 '24 19:05 burcugen