I got an issue. I am at the opening page of my app, which is stful widget. In the middle of the screen is a button, and a container below. In the container appears random numbers every some time. How can I solve the problem, where I want to create ListView.builder at the Second Page, which is also stful widget. I need him to be stful. I want to create ListView according to the numbers at the first page, by clicking the button and sending data to the Listview.builder. I need a simple solution how to manage this case. All my trails failed. It would be fantastic for a help!
as I understand you should keep one int array and set random numbers into the array, then on the second page, you need a constructor to take data, then in init state set them. The second page should be as below example.
class SecondPage extends StatefulWidget {
final List<int> data;
SecondPage(this.data);
@override
_SecondPageState createState() => _SecondPageState();
}
class _SecondPageState extends State<SecondPage> {
List<int> _list = List<int>();
@override
void initState() {
_list = widget.data;
super.initState();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.