The solution is very simple......
Just add `with AutomaticKeepAliveClientMixin<Tab1>` can be solve.<br>
Thanks Aldy.
import 'dart:convert';
import 'package:http/http.dart' as http;
import "package:flutter/material.dart";
class Tab1 extends StatefulWidget {
String input;
@override
_Tab1 createState() => _Tab1();
}
class _Tab1 extends State<Tab1> with AutomaticKeepAliveClientMixin<Tab1> {
TextEditingController doorNumberController = new TextEditingController();
void initState() {
super.initState();
//doorNumberController.text=input;
}
@override
Widget build(BuildContext context) {
return Card(
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Text('Room:', textAlign: TextAlign.left,style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w900,
fontSize: 25),
),
Container(
width: 250.0,
child: TextField(
controller: doorNumberController,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Room number:',
),
),
),
]
),
Row(
children:<Widget>[
IconButton(
icon: const Icon(Icons.save),
color: Colors.blue,
onPressed: () {
print(doorNumberController.text);
},
),
]
)
]
)
);
}
bool get wantKeepAlive => true;
}
You can add `Container` and `ListView` in `Column`.
```dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text("Demo App1"),
),
body: Column(
children: <Widget>[
Container(
height: 40.0,
child: Row(
children: <Widget>[
Container(
padding: EdgeInsets.all(4.0),
width: 100.0,
child: Text(
"Name",
style: TextStyle(fontSize: 18),
)),
Container(
padding: EdgeInsets.all(4.0),
width: 100.0,
child: Text(
"Age",
style: TextStyle(fontSize: 18),
)),
],
),
),
Expanded(
child: ListView.builder(
itemCount: 100,
itemBuilder: (BuildContext context, int index) {
return Row(
children: <Widget>[
Container(
padding: EdgeInsets.all(4.0),
width: 100.0,
child: Text(
"Name $index",
style: TextStyle(fontSize: 18),
)),
Container(
padding: EdgeInsets.all(4.0),
width: 100.0,
child: Text(
"Age $index",
style: TextStyle(fontSize: 18),
),
)
],
);
},
),
),
],
),
),
);
}
}
```