Home > Blockchain >  Return two design elements in builder
Return two design elements in builder

Time:05-23

       Widget build(BuildContext context) {
    super.build(context);
    return Scaffold(
...
...
...

builder: (BuildContext context) { //BuildContext context
              final innerScrollController = PrimaryScrollController.of(context);
              return TabMedium(
                sc: innerScrollController,
                tc: _tabController,
              );
              return  BannerAdAdmob();            
            }

For now, it shows only TabMedium() view. How can I put top & bottom these views?

What do I get?

enter image description here

What do I want?

enter image description here

Thanks...

CodePudding user response:

Did you try Column ??

Widget build(BuildContext context) {
super.build(context);
return Scaffold(
...
...
...
builder: (BuildContext context) { //BuildContext context
          final innerScrollController = PrimaryScrollController.of(context);
          return Column(
         
           children:[
             Expanded(
               child:TabMedium(
                       sc: innerScrollController,
                       tc: _tabController,
               ),
             ),
             BannerAdAdmob(),
           ],
          );         
        }

CodePudding user response:

You can not add two return, only first return will be executed. If you want to show two widget as you show in the picture you can use Column.

       Widget build(BuildContext context) {
    super.build(context);
    return Scaffold(
...
...
...

builder: (BuildContext context) { //BuildContext context
              final innerScrollController = PrimaryScrollController.of(context);
              return Column(
               mainAxisSize: MainAxisSize.max,
               children:[
                 Expanded(
                   child:TabMedium(
                           sc: innerScrollController,
                           tc: _tabController,
                   ),
                 ),
                 BannerAdAdmob(),
               ],
              );         
            }

CodePudding user response:

this happens bcs you just return one of them.

try to put them in a Column, maybe like this:

(I did not Compiled it but it should work)

builder: (BuildContext context) { //BuildContext context
          final innerScrollController = PrimaryScrollController.of(context);
          return Column(
           mainAxisSize: MainAxisSize.max,
            children[
              TabMedium(
              sc: innerScrollController,
              tc: _tabController,
              ),
              BannerAdAdmob(),  
            ],


          );
          
              
        }
  • Related