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.7k stars 551 forks source link

[Flutter] Add 'stless' and 'stful' template shortcuts. #1278

Open johnsonmh opened 5 years ago

johnsonmh commented 5 years ago

Android studio has common Flutter templates. By typing stless hitting <cntrl> + <space> and then hitting enter, you can very easily create a new stateless widget.

giphy

A very similar thing happens for entering stful -> hitting <cntrl> + <space> -> hitting <enter>.

giphy-1

These shortcuts are great time savers and would be awesome to have in DartPad. This is not the most high priority feature though, just nice to have.

RedBrogdon commented 5 years ago

This would definitely be a great change, if for no other reason than I use them in IntelliJ (which calls them "Live Templates") a lot.

One issue is that LiveTemplates are a feature of IntelliJ rather than the analysis server or CodeMirror. I'm not sure how much work would be required to implement these.

Does anyone have an example of a site based on CodeMirror that's implemented this type of template expansion?

devoncarew commented 5 years ago

FYI, the IntelliJ Flutter live templates are defined here:

https://github.com/flutter/flutter-intellij/blob/master/resources/liveTemplates/flutter_miscellaneous.xml

bu that may not necessarily help with implementing them in dartpad.

domesticmouse commented 4 years ago

If the intent is to implement a full code editor, we could use https://github.com/cdr/code-server to take full advantage of the dart and flutter editing support already implemented by @DanTup instead of implementing yet another editor

johnsonmh commented 4 years ago

That's a great idea, I didn't know we could leverage existing code server logic. I'm all for that!