Is Flutter capable of dynamically loading and building widgets during runtime?


Is there any by which I can store multiple dart files on some server and retrieve any one of those file during run-time in such a way that Flutter is able to build a particular widget from the file it receives?


You cannot dynamically load dart files or create new classes, no.

On the other hand, the widget tree is created at runtime, and widgets are composable by nature. So it is totally possible to make a function that deserialize some data into a widget tree.

We could, for example, write a widget tree as an xml/yaml/whatever like so:

type: Row
  - type: Container
    color: red
      - type: Text
        0: hello world

And have a function deserialize it into:

  children: [
      child: Text('hello world'),

Answered By – Rémi Rousselet

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published