I have a class where there are 2 Tabs (used DefaultTabController) . AppBar have Action button/Text to save the Edited Text in each tab either It may tab0 or tab1. Both Tabs are separate stateful widget . I don't know, how to get How to get EditedText/String from a tab when save action is pressed in main Class ?
I looked into the similar Question but didn't get idea from it Flutter: send Data from TabBarView (StatefullWidgets) back to main Scaffold your help would be appreciated .Thanks a lot.
class EditPocketMoney extends StatefulWidget {
@override
_EditPocketMoneyState createState() => _EditPocketMoneyState();
}
class _EditPocketMoneyState extends State<EditPocketMoney> {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Scaffold(
backgroundColor: Theme.of(context).primaryColor,
appBar: AppBar(
elevation: 0.0,
automaticallyImplyLeading: false,
leading: IconButton(icon: Icon(Icons.clear,color: Color(0xffE44663),), onPressed: (){Navigator.pop(context);}),
title: Text('Edit',style: TextStyle(color: Colors.white,fontFamily: 'SF Pro Text',fontSize: 17.0, ),),
centerTitle: true,
actions: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: (){
},
child: Container(
margin:EdgeInsets.only(right:15.0 ),
child: Text('SAVE',style: TextStyle(color: Color(0xffE44663),fontFamily: 'SF Pro Text',fontSize: 17.0, ),)),
),
],
),
],
bottom: PreferredSize(
preferredSize: Size(MediaQuery.of(context).size.width*0.8, 45.0),
child: Container(
margin: EdgeInsets.only(left: 18.0,right: 18.0,top: 5.0),
child: TabBar(
unselectedLabelColor: Colors.white,
labelColor:Colors.black ,
labelPadding: EdgeInsets.all(8.0),
tabs: [
Center(child: Text('Per Day',style: TextStyle(fontSize: 15.0,fontWeight: FontWeight.w600),)),
Center(child: Text('Per Month',style: TextStyle(fontSize: 15.0,fontWeight: FontWeight.w600),)),
],
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: Colors.white,
),),
),
),
),
body: TabBarView(children: [
PocketMoneyPerDay(),
PocketMoneyEditPerMonth()
])
),
);
}