ClojureDart:主机编译时出错 (ns samples.tables (:require ["package:flutter/material.dart" :as m] [cljd.flutter.alpha as f]))

ClojureDart: Error while host-compiling (ns samples.tables (:require ["package:flutter/material.dart" :as m] [cljd.flutter.alpha as f]))

这是痕迹:

Something horrible happened! :scream: Error while host-compiling (ns samples.tables "Faithful port of https://docs.flutter.dev/cookbook/design/tabs" (:require ["package:flutter/material.dart" :as m] [cljd.flutter.alpha as f])) (ns samples.tables "Faithful port of https://docs.flutter.dev/cookbook/design/tabs" (:require ["package:flutter/material.dart" :as m] [cljd.flutter.alpha as f])) Can't resolve widgets/InheritedModel (no source location)

这是我的代码:

(ns samples.tabs
  "Faithful port of https://docs.flutter.dev/cookbook/design/tabs"
  (:require
   ["package:flutter/material.dart" :as m]
   [cljd.flutter.alpha as f]))

(defn main
  []
  (let [title "Tabs Demo"]
    (m/runApp
     (m/MaterialApp
      :title title
      :home
      (m/DefaultTabController
       :length 3
       :child 
       (m/Scaffold
        :appBar 
        (m/AppBar
         :bottom
         (m/TabBar 
          :tabs [(m/Tab :icon (m/Icon. m.Icons/directions_car)),
                 (m/Tab :icon (m/Icon. m.Icons/directions_transit)),
                 (m/Tab :icon (m/Icon. m.Icons/directions_bike))]))
        :body 
        (m/TabBarView 
         :children [(m/Tab :icon (m/Icon. m.Icons/directions_car)),
                    (m/Tab :icon (m/Icon. m.Icons/directions_transit)),
                    (m/Tab :icon (m/Icon. m.Icons/directions_bike))])))))))

我们可以注意到跟踪中提到了模块的所有声明和要求,但也不是很明确。你也可以认为是widget库有问题

首先,请确保您有

dependencies:
  flutter:
    sdk: flutter

在你的 pubspec.yaml 中;它用于 clojureDart 查找 flutter 库。 如果没有,添加它,删除.clojuredart文件夹,运行 flutter pub get和t

可以看到错误出现在文件开头,符合要求。 其实我只是忘了在关键词:as.

后面加上:

[cljd.flutter.alpha as f] -> [cljd.flutter.alpha :as f]