Pass initial values to Controller #88
-
I'm not sure if this section of the repo is monitored but I'll post here just in case. I would like to create a widget that receives initial values of a list of items and an initial index through its constructor. The index would then update through a 'next' and 'previous' type of interaction. If I have understood this architecture correctly, I believe the Controller would be responsible for moving the index through the list of items and the widget would do something like My question is, how do I get these initial values into the Controller? I currently have the implementation below, where the
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Hi @stevegcc, this is the intended usage as shown in the example below: What is the linter message exactly? The return type in this line must match the type of the ViewState you're using. I think in your case it's _WorkflowViewState? Although you seem to be constructing a _ExerciseWorkflowViewState, which I cannot see in the example you posted.
Should be
Let me know if that resolves it for you. |
Beta Was this translation helpful? Give feedback.
-
Thanks @ShadyBoukhary and apologies, I meant to include the linting error in the first post. This is the error I receive https://dart-lang.github.io/linter/lints/no_logic_in_create_state.html I also made a mistake with the I have the copy of the index and items in the view because I am displaying this view in a What's the best method for getting these values into the controller? I am newish to Flutter and I don't seem to be able to find another way other than the source view passing the values into the new view via the constructor, which then needs to pass into the state and then the Controller. Do I need to put them into storage and retrieve them? This is possibly another question for another thread, however, before I refactored to use a BottomSheet, I was passing route parameters, extracting in the ViewState and setting the values in the Controller during the build method. This meant the items and index were mutable and I wasn't comfortable with that. Is there a way to access Route parameters in the Controller as well? |
Beta Was this translation helpful? Give feedback.
-
Marking this comment as an answer |
Beta Was this translation helpful? Give feedback.
Marking this comment as an answer
#88 (reply in thread)