I want to create an app which has a TabBarView with two tabs. On the first Tab there is a Textfield and on the other tab there is a text widget which should display the text which you entered into Textfield but I always get an error because text is null.( I'm new in programming with flutter)
I tried to initialize the variable in TextOutput class but it didn't work because the variable is final.
TabBarView(
children: <Widget>[
TextCreatePage(), TextOutput()
],
class TextCreatePageState extends State<TextCreatePage> {
String textvalue;
@override
Widget build(BuildContext context) {
return Center(child: TextField(
onChanged: (String value) {
setState(() {
textvalue = value;
TextOutput(textvalue: textvalue,);
});
class TextOutput extends StatelessWidget {
final String textvalue;
TextOutput({this.textvalue});
@override
Widget build(BuildContext context) {
return Text(textvalue);
}
}