• Stars
    star
    1,338
  • Rank 33,804 (Top 0.7 %)
  • Language
    Clojure
  • Created over 3 years ago
  • Updated 14 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Clojure dialect for Flutter and Dart

What is ClojureDart?

ClojureDart is a Clojure dialect for Dart (2.13+ and 3) and Flutter.

It's production-ready: you can ship applications with it right now.

Its primary goal is to leverage Dart and Flutter to extend Clojure's reach to mobile and desktop apps.

Status

We stay true to Clojure philosophy and we will avoid breaking changes at all cost.

Work is not complete, some features are missing:

  • no REPL yet, but we have excellent hot-reload so for UI work you get instant feedback
  • multi-method (WIP)

Support

Stop by the Clojurians #ClojureDart channel or open an issue.

If you are betting the farm on ClojureDart, we can offer you paid support and assistance.

You can help us spend more time on ClojureDart by sponsoring ❀️ Baptiste or ❀️ Christophe.

Cheatsheet

We have a cheatsheet covering ClojureDart specifics on one side and Flutter programming on the other side.

Conj 2023

Want to see what's the workflow like? Our talk at Clojure/Conj 2023 is mostly a live-coding session, starting from scratch and assuming no prior knowledge of Dart or Flutter!

https://www.youtube.com/watch?v=dqBeGpuedf0&list=PLZdCLR02grLpIQQkyGLgIyt0eHE56aJqd&index=24

Links dump

Slack Youtube Twitter

Your first app!

Prerequisites: Clojure and Flutter installed and on your path.

Create a project directory with its deps.edn

mkdir hello
cd hello
cat << EOF > deps.edn
{:paths ["src"] ; where your cljd files are
 :deps {tensegritics/clojuredart
        {:git/url "https://github.com/tensegritics/ClojureDart.git"
         :sha "5ac0b6ccecd8a41e1a317e164dfc2dd9062d739a"}}
 :aliases {:cljd {:main-opts ["-m" "cljd.build"]}}
 :cljd/opts {:kind :flutter
             :main acme.main}}
EOF

(To update an existing project to the latest ClojureDart, just do clj -M:cljd upgrade)

Initialize project:

clj -M:cljd init

Add some source code:

mkdir -p src/acme
cat << EOF > src/acme/main.cljd
(ns acme.main
  (:require ["package:flutter/material.dart" :as m]
            [cljd.flutter :as f]))

(defn main []
  (f/run
    (m/MaterialApp
      .title "Welcome to Flutter"
      .theme (m/ThemeData .primarySwatch m.Colors/pink))
    .home
    (m/Scaffold
      .appBar (m/AppBar
                .title (m/Text "Welcome to ClojureDart")))
    .body
    m/Center
    (m/Text "Let's get coding!"
       .style (m/TextStyle
                .color m.Colors/red
                .fontSize 32.0))))
EOF

Compile, watch and run:

clj -M:cljd flutter

In most environments this will spawn a desktop app.

More details there

Who is behind it?

Tensegritics, an itty-bitty Clojure consultancy by Baptiste Dupuch🐦 and Christophe Grand🐦.

ClojureDart is not a revenue source for us, even if we build it for fun and hopefully profit -- by being the proverbial rising tide which lifts all boats.

Sponsoring us is a good way to get the project moves faster. In the past sponsorship money allowed us to have an intern on the project writing samples and producing videos.

Obviously you can contract us for assistance or development with ClojureDart.

Quick starts

Examples

In the samples directory directory, you'll find original sample code and ports of Flutter recipes.

How to run a sample project

Clone the ClojureDart repo.

git clone https://github.com/Tensegritics/ClojureDart.git

Go to the sample you want to try, let's say fab:

cd ClojureDart/samples/fab

Init the project:

clj -M:cljd init

Then launch the watcher:

clj -M:cljd flutter

You should get the sample running either in Chrome or as a desktop app.

To specify your exact target you must run flutter devices which outputs something like:

3 connected devices:
iPhone 6s (mobile) β€’ D6707352-78D2-46BB-AB95-87355283FC82 β€’ ios            β€’
com.apple.CoreSimulator.SimRuntime.iOS-15-5 (simulator)
macOS (desktop)    β€’ macos                                β€’ darwin-arm64   β€’
macOS 12.4 21F79 darwin-arm
Chrome (web)       β€’ chrome                               β€’ web-javascript β€’
Google Chrome 103.0.5060.114

The second column is the id of the target (here D6707352-78D2-46BB-AB95-87355283FC82, macos or chrome) that you pass to the watcher:

clj -M:cljd flutter -d D6707352-78D2-46BB-AB95-87355283FC82

Enjoy! πŸ§ƒ

cljd.flutter

cljd.flutter is an utility namespace to remove Flutter boilerplate and integrate more nicely with Clojure.

cljd.flutter.alpha

Deprecated, use cljd.flutter.

cljd.flutter.alpha2

Got out of alpha status and lives a happy life as cljd.flutter.

Thanks!

To all individuals who blindly believed in our endeavor and sponsored our work.

To NuBank who approached us very early for sponsorship.

To Roam Research who bet their mobile apps development (now in the App Store and Play Store) on ClojureDart and allowed us to make steady progress since Summer 2021.

If you want to sponsor our work, you can sponsor either of us, we'll balance sponsorship. If you are a company you can also contact us directly.