飞镖字符串插值读取文件 [英] Dart string interpolation reading a file

查看:74
本文介绍了飞镖字符串插值读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以使用字符串插值来引用字符串文字中的对象,但是通过读取文本文件给出的字符串是否可能呢?

I know that you can use the string interpolation to reference an object within a string literal but, is this possible with a string given from reading a text file?

我的意思是。

Function MyTemplate() {
    return (Context context) {
        return readMyFile(); // String: "My name is ${context.name}"
    }
}

我已阅读
我可以动态应用Dart的字符串插值吗

但这似乎仅适用于硬编码字符串。

But this seems to work only with hardcoded strings.

推荐答案

字符串插值仅适用于硬编码的字符串。您需要构建自己的解决方案或使用现有的模板包之一。

String interpolation only works with hardcoded strings. You need to build your own solution or use one of the existing template packages.

这篇关于飞镖字符串插值读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆