Son*_*low 1 dart flutter flutter-layout
有没有什么方法可以让我在某个服务器上存储多个 dart 文件并在运行时检索这些文件中的任何一个,从而使 Flutter 能够从它收到的文件中构建一个特定的小部件?
您不能动态加载 dart 文件或创建新类,不。
另一方面,小部件树是在运行时创建的,小部件本质上是可组合的。因此,完全有可能制作一个将某些数据反序列化为小部件树的函数。
例如,我们可以将小部件树编写为 xml/yaml/任何类似的东西:
type: Row
children:
- type: Container
color: red
child:
- type: Text
0: hello world
Run Code Online (Sandbox Code Playgroud)
并有一个函数将其反序列化为:
type: Row
children:
- type: Container
color: red
child:
- type: Text
0: hello world
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1346 次 |
| 最近记录: |