Streams-Block-Reactive-Programming-in-Flutter icon indicating copy to clipboard operation
Streams-Block-Reactive-Programming-in-Flutter copied to clipboard

Bloc modelview is called when using textfield (keyboard show/hide)

Open x4080 opened this issue 6 years ago • 1 comments

Hi, I like your Bloc provider and tried to use it but found something strange : Modelview is called when using textfield (keyboard show/hide), what I mean the modelview is

return BlocProvider<SearchTableModelView>( bloc: SearchTableModelView(), child: TestPage());

(in above case its SearchTableModelView), and strangely it's not happening if it is in the root of the app, but if we use Navigator.push for it like

class SearchPageRoute extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider<SearchTableModelView>( bloc: SearchTableModelView(), child: TestPage()); }

The initialization of the ModelView is called everytime keyboard show/hide (in the SearchPage) but the dispose method is only called once

Is this a flutter bug ?

Edit :

  • When entering the searchPage, if TextField autofocus is false, modelView init is called once (correct)
  • If I click the TextField, keyboard show up, and modelView init is called again
  • If I dismiss the TextField, keyboard hide, and modelView init is called again
  • and so on

Thanks

x4080 avatar Apr 03 '19 07:04 x4080

Did you manage to find a solution to this @x4080 that does not include using StatefulWidget?

vstene avatar Jul 02 '19 21:07 vstene