amake / flutter.el

Flutter tools for Emacs
GNU General Public License v3.0
123 stars 11 forks source link

More Flutter commands #10

Open Davoodeh opened 4 years ago

Davoodeh commented 4 years ago

Hi, thanks for the incredible job here! Been using the package for a couple of days now. Just saw the package lacking some essential commands (in order to keep us in the Emacs only xD) (and since I'm a noob in writin Lisp thought I just come here and say what I think instead of making a Pull request).

Just the absence of a functions like: flutter-create is a big deal. (and pub) It would be nice to implement such commands in here too.

amake commented 4 years ago

Thanks for the kind words.

I don't see flutter create as a priority because it's a one-time event in the lifecycle of a project, and could add significant maintenance burden (following upstream changes to the interface).

PRs are always welcome, though.

Davoodeh commented 4 years ago

Thanks a lot! I leave this open in case somebody gets inspired to write it (or myself if I ever learn enough xD)

zhaozhixu commented 1 month ago

What about flutter pub run build_runner build, which is quite common in generate JSON serialization code etc?

Or perhaps better, provide some hook point so we can customize commands for running before flutter run (perhaps using project root as working directory)?

Thanks for the awesome package!

zhaozhixu commented 4 weeks ago

What about flutter pub run build_runner build, which is quite common in generate JSON serialization code etc?

Or perhaps better, provide some hook point so we can customize commands for running before flutter run (perhaps using project root as working directory)?

Thanks for the awesome package!

For those who have the same needs, my flutter package config is:

(defun my-flutter-build-run-watch ()
  "Run `flutter pub run build_runner watch`."
  (interactive)
  (flutter--from-project-root
   (let* ((buffer-name "*Flutter-build-runner-watch*")
          (buffer (flutter--get-buffer-create buffer-name))
          (alive (comint-check-proc buffer-name)))
     (unless alive
       (progn (apply #'make-comint-in-buffer "Flutter-build-runner-watch" buffer (flutter-build-command) nil '("pub" "run" "build_runner" "watch"))
              (display-buffer buffer))))))

(defun my-flutter-run-or-hot-reload ()
  "Run 'flutter run' or perform a hot reload, and open the *Flutter* buffer."
  (interactive)
  (my-flutter-build-run-watch)
  (flutter-run-or-hot-reload)
  (switch-to-buffer-other-window "*Flutter*"))

This opens a process buffer calling flutter pub run build_runner watch in the first time flutter runs, and stays background watching file changes and generating code.