'How to add multiple child inside a Scaffold

I want to add a button, below the listview to navigate to the next page! But I am unsure of the layout.

@override
 Widget build(BuildContext context)
 {
   return Scaffold(
     appBar: AppBar(
       title:const Text("Welcome"),
       centerTitle: true,
     ),
     body:Center(
       child:SizedBox(
           child:ListView.separated(
             padding: const EdgeInsets.all(8),
             itemCount: entries.length,
             itemBuilder: (BuildContext context, int index) {
               return Container(
                 height: 50,
                 color: Colors.amber[colorCodes[index]],
                 child: Center(child: Text('Entry ${entries[index]}')),
               );
             },
             separatorBuilder: (BuildContext context, int index) => const Divider(),
           )
               child: TextButton(onPressed: onPressed, child: child) // Where am i suppose to add this?
       )
     )
   );

I am unsure of the layout! Any help will be greatly appreciated!



Solution 1:[1]

Simply wrap the ListView with a Column:

@override
 Widget build(BuildContext context)
 {
   return Scaffold(
     appBar: AppBar(
       title:const Text("Welcome"),
       centerTitle: true,
     ),
     body:Column(
children: [
     Center(
       child:SizedBox(
           child:ListView.separated(
             padding: const EdgeInsets.all(8),
             itemCount: entries.length,
             itemBuilder: (BuildContext context, int index) {
               return Container(
                 height: 50,
                 color: Colors.amber[colorCodes[index]],
                 child: Center(child: Text('Entry ${entries[index]}')),
               );
             },
             separatorBuilder: (BuildContext context, int index) => const Divider(),
           )
               child: TextButton(onPressed: onPressed, child: child) // Where am i suppose to add this?
       )
     ),
],
   );

After you done this, you can add as many widgets as you want.

Hope it helps!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1