dart-lang / dart-pad

An online Dart editor with support for console, web, and Flutter apps
https://dartpad.dev
BSD 3-Clause "New" or "Revised" License
1.71k stars 557 forks source link

Add a way of interacting with the app you build #819

Closed filiph closed 11 months ago

filiph commented 6 years ago

Dart is a "client-optimized language", so most folks are trying to build things that are interactive in some way.

Right now, the only way of building anything interactive in DartPad is using HTML. Which is a cognitive load, and wasted effort for newcomers who don't want to deal with HTML (e.g. Flutter newcomers).

One way of doing user interaction is to allow importing dart:io, but 99% of dart:io is unnecessary for this scenario. And I'm sure that would mean a lot of security work on top.

@kwalrath proposed a custom stream of events. Here's how it would work (in my understanding):

The cool thing about this is that:

cc @montyr75

kwalrath commented 6 years ago

To be clear, @filiph thought of almost all of this. :) But I'd love a way to make DartPad a bit more client friendly without requiring HTML. Streams, in particular, are pervasive but can be hard to understand until you use them.

devoncarew commented 6 years ago

So to paraphrase a bit, instead of just stdout, have the snippet run in a container environment, with some way for the snippet to get events from the container, and provide feedback to it. Perhaps a bit like a micro version of http://processingjs.org/? Having a special package: import or similar to make the container's inputs available makes sense.

We're teaching streams and reactive programming from the get go.

Smaller demos of the streams API could also be taught via periodic Timer events.

filiph commented 6 years ago

@devoncarew Yes. Very well put, and the simile to Processing is great (although, of course, we'd be a long way behind what processing can do).

Timer works, but I think it's significantly more educational/visceral/interesting when you can "play" around with the code you build.

filiph commented 6 years ago

This relates to https://github.com/dart-lang/dart-pad/issues/820 (remove the ability to write and execute html in the snippets).

RedBrogdon commented 5 years ago

@filiph @devoncarew Where do you stand on this idea in relation to flutter_web? Would it be simpler to provide the dev with Flutter code pre-built (possibly in a test tab as we do in the new embed UI) and then let them hook into that with their Dart? That would allow us to use and flutter_web infrastructure and still give them an interactive experience.

filiph commented 5 years ago

That would be the absolute best, yes. If we have a Flutter view to interact with, there is no need to implement a separate thing described above.

parlough commented 11 months ago

That would be the absolute best, yes. If we have a Flutter view to interact with, there is no need to implement a separate thing described above.

Since building simple Flutter web apps is supported by DartPad now, I'm going to close this as we can support all types of interaction through that view :)