I am building a Bluetooth connection application with the following tabs. The device is the device I connected to, and forwardingIP is the IP of the device I want to control indirectly through the Device
Outside the screen, I create a FloatingActionButton, to scan and select the devices I want to control (forwardingIP).
I want when I choose new forwardingIP it will also update in my tabs, what to do?

body: TabBarView(
children: [
General(device : widget.device, IP: forwardingIP),
Control(device : widget.device, IP: forwardingIP),
Info(device : widget.device, IP: forwardingIP),
]
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.red[600],
onPressed: (){},
child: Icon(Icons.playlist_play),
),

trannhoduc “final” variables cannot be changed.
use this

var device;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    device = widget.device;
  }
Widget build(BuildContext context) {
    return Scaffold(
    appbar :Appbar(),
body: TabBarView(
children: [
General(device : device, IP: forwardingIP),
Control(device : device, IP: forwardingIP),
Info(device : device, IP: forwardingIP),
]
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.red[600],
onPressed: (){
device = ... ; 
forwardingIP = ... ; //change variables
 setState(() {
 }); // Changes are applied to the screen using "setstate"
},
child: Icon(Icons.playlist_play),
),
);
}
    Write a Reply...