Flutter - Storing Widgets in Firebase?

Viewed 185

I am wondering whether it is possible to store Widgets(code) in Firebase?

Reason: I want the user to create a form that is specific to that user, so they can add / remove fields. Clients of the user can then fill that form out based on what fields the user wants.

I have read in other Stackflow Questions for other languages that they convert the code .toString() and store it as a String.

Any feedback would be appreciated!

2 Answers

Storing widgets won't be that much standard. See, the type of fields aren't infinite. What's infinite in your context is how many fields one user can have and the sequence of input fields (Just like a Google Form creation process).

One idea is that you store the sequence of input fields the user has selected and in each sequence you store the label, placeholders of those input fields which are common. Then retrieve those data from fire-base and display with the help of enum.

Yes, you are correct, it's possible to store codes in Firebase, using Flutter. As you mentioned, using the toString() - described in the official Flutter API here - it's possible to override and convert any formats to String, which can be stored in Firebase as you prefer.

However, please, consider checking and verifying the code added, as this is not the better solution and won't be able to add any code to your application as a field. Adding to that, when the code is brought back from the database, you should be able to use it as fields, once you convert the code.

Let me know if the information clarified!

Related