テンプレートの問題のある部分は次のとおりです。
<ul id="list">
<template iterate='file in convertedfiles.files'>
<li>{{file.filename}}
<template if='file.isImage'>
<img src="{{file.src}}" alt="{{file.filename}}"><br/>
Source: {{file.src}}
</template>
</li>
</template>
</ul>
ConvertedfilesはAndroidFileのリストです。
class AndroidFile {
File _file;
String filename;
String src;
bool isImage;
AndroidFile(this._file) : isImage = false {
filename = htmlEscape(_file.name);
// If the file is an image, read and display its thumbnail.
if (_file.type.startsWith('image')) {
FileReader reader = new FileReader();
reader.on.load.add((e) {
src = reader.result.toString().trim();
// prints the correct URL (data:image/png;base64,...)
print(src);
isImage = true;
watcher.dispatch();
});
reader.readAsDataUrl(_file);
}
}
}
テンプレートが表示されます。ファイル名が表示され、ソースが表示されますが、imagetagは次のようになります。
<img alt="screenshot-1179.png" src="#">
ハッシュには下線が引かれ(Chromiumソースビューで)、クリックすると「ファイルが見つかりません:/ web /out/」と表示されます。
ChromeでJSに変換されると、「リソースは画像として解釈されますが、MIMEタイプtext/htmlで転送されます」と表示されます。
サンプルソースはGitHub
にあり
ますヒントはありますか?