CopyPastor

Detecting plagiarism made easy.

Score: 0.8204105496406555; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2022-09-25
by D. S. Shatner

Original Post

Original - Posted on 2020-06-15
by Lapa Ny Aina Tanjona



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You can simply create a list containing all widgets to spread in the `PageView()` as shown below.
List<Widget> allWidgets = []; body: PageView( controller: controller, scrollDirection: Axis.vertical, child: Column( children: <Widget>[ SizedBox( child: PageView( scrollDirection: Axis.horizontal children: [ ...allWidgets ]), ), Widget3(), Widget4(), widget5(), widget6(), ], ), ),

And add your custom widgets which are all have their own `FutureBuilder()` as you just said to `allWidgets` List. You can do this with `if(snapshot.HasData){}` as you can see in example.
class Widget1 extends StatefulWidget { Widget1({Key? key}) : super(key: key); @override State<Widget1> createState() => _Widget1State(); } class _Widget1State extends State<Widget1> { @override Widget build(BuildContext context) { return Scaffold(body: FutureBuilder( future: someData, builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData) { allWidgets.add(Widget1()); return Container(); }else{ return CircularProgressIndicator(); } }, ), ); } }

Here is a demonstration with your example for a Future type in a datatable widget:
return Scaffold( appBar: AppBar( title: Text("Sale list"), ), body: FutureBuilder( future: apiService.getData(), builder: (context, snapshot) { if(!snapshot.hasData) { return Center(child: CircularProgressIndicator()); } if(snapshot.hasData) { return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, verticalDirection: VerticalDirection.down, children: <Widget>[ Expanded( child: Container( padding: EdgeInsets.all(5), child: dataBody(snapshot.data) ), ) ], ); } return Center(); }, ), );
SingleChildScrollView dataBody(List<Sale> listSales) { return SingleChildScrollView( scrollDirection: Axis.vertical, child: DataTable( sortColumnIndex: 0, showCheckboxColumn: false, columns: [ DataColumn( label: Text("Next"), numeric: false, tooltip: "Next" ), DataColumn( label: Text("Previous"), numeric: false, tooltip: "Previous", ), ], rows: listSales .map( (sale) => DataRow( onSelectChanged: (b) { print(sale.next); }, cells: [ DataCell( Text(sale.next) ), DataCell( Text(sale.previous), ), ]), ) .toList(), ), ); }
Hope this can help you!

        
Present in both answers; Present only in the new answer; Present only in the old answer;