0

I'm having an issue: The CreatePostWidget is accepting a model object called Post. If it receives an empty Post you're creating a new one. If it receives a post it means you're editing one. The post has been passed from the widget to the viewmodel in the didChangeDependencies meethod:

@override
  void didChangeDependencies() {
    viewModel = Provider.of<PostsViewModel>(context);
    viewModel.setPost(widget.post);
    super.didChangeDependencies();

Unfortunately this widget get built multiple times since it's a form and the keyboard goes up and down and the setPost keeps resetting the TextEditingControllers present in the ViewModel.

What am i doing wrong? How can avoid the viewmodel to be provided with the context and not being resetted constantly ?

Thanks

0 Answers0