title: Flutter is not rebuilding same widget with different parameters
body: <p>I was working with bottom navigation with similar child widgets in which only parameters are changed. The problem only happens when widgets are of <strong>StatefulWidget</strong> else  there is no problem, indications in bottomnavbar is changing but not the body.</p>
  
  <p><strong>Child 1:</strong>
  <a href="https://i.stack.imgur.com/hqzPW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hqzPW.png" alt="enter image description here"></a></p>
  
  <p><strong>Child 2:</strong>
  <a href="https://i.stack.imgur.com/4KYxi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4KYxi.png" alt="enter image description here"></a></p>
  
  <p><strong>Actual result:</strong>
  <a href="https://i.stack.imgur.com/XF05y.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/XF05y.gif" alt="enter image description here"></a></p>
  
  <pre><code>class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  
  @override
  _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
  int _counter = 0;
  Widget body;
  @override
  void initState() {
  //    body = getBody(0);
  super.initState();
  }
  
  @override
  Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text(widget.title),
      elevation: 0,
    ),
    body: body,
    bottomNavigationBar: BottomNavigationBar(
      currentIndex: _counter,
      onTap: (index){
        _counter = index;
        setState(() {
          body = getBody(index);
        });
      },items: [
      BottomNavigationBarItem(icon: Icon(Icons.language),title: 
   Text('HELLO')),
      BottomNavigationBarItem(icon: Icon(Icons.security),title: 
  Text('BYE'))
    ]),
   );
  }
  Widget getBody(int pos){
  if(pos==0){
  //      return new Mx(category: 'ALPHA',type: '@',);
    return new MyTAbs(category: 'ALPHA',type: '@',);
  }
  else{
  //      return new Mx(category:'BETA',type: '#',);
    return new MyTAbs(category:'BETA',type: '#',);
    }
   }
  }
  class Mx extends StatelessWidget{
  final String type,category;
  Mx({this.type,this.category});
  @override
  Widget build(BuildContext context) {
   return new Scaffold(
    backgroundColor: getColor(),
    body: new Center(
      child: Text(category+' '+type),
    ),
   );
  }
  Color getColor(){
  if(category=='ALPHA'){
    return Colors.red;
  }
  else{
    return Colors.green;
    }
   }
  }
  class MyTAbs extends StatefulWidget{
  final String type,category;
  MyTAbs({this.type,this.category});
  Tabs createState() =&gt; new Tabs(title: category,type: type);
  }
  class Tabs extends State&lt;MyTAbs&gt;{
  final String title,type;
  Tabs({this.title,this.type});
  @override
  Widget build(BuildContext context) {
  // TODO: implement build
  return new Scaffold(
    backgroundColor: getColor(),
    appBar: AppBar(
      title: Text(title+' '+type),
    ),
  );
  }
  Color getColor(){
  if(title=='ALPHA'){
    return Colors.red;
  }
  else{
    return Colors.green;
    }
   }
  }
  </code></pre>
  
  <p>and I can't use <strong>statelessWidget</strong> because there's a dynamic tab section inside.</p>