1

I need to invoke some Widgets, many Widgets, with names as S1, S2, S3, and so on. Is it possible to use any variable to do this? Something like:

builder: (context) => S'$i'(),     // with i variable as a counter, for example

instead of

builder: (context) => S1(),
builder: (context) => S2(),
builder: (context) => S3(),

I appreciate your help. Regards

1
  • If you are needing to do this, it is probably a good sign that you should use some sort of abstraction or inheritance in your classes Commented Jun 15, 2020 at 23:15

1 Answer 1

2

No, it's not possible. I would suggest you use Streambuilder to build your dynamic views.

Sign up to request clarification or add additional context in comments.

3 Comments

Ok @Keezy Silencer, I appreciate your help
@KeezySilencer I need to show a different widget depending on a state varialble- Is streambuilder appropriate for this case?
@user3808307 That is the way to go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.