skip to Main Content

I want to call a function inside Wrap content. My requirement is to call this function before the wrap content is loaded.

 void checkFund(){}

    Wrap(
    children: entList
        .map((element) => Padding(
    
    padding: const EdgeInsets.only(left: 4.0, bottom: 5),
    
    child: element['isAcq']
    ? Acquisition('${element['ele']}')
    : element['isPartner']
    ? GestureDetector(
    // onTap: () {
    //   print('partner');
    // },
    child: NewPartnerShip(
    '${element['ele']}',
   )
    : element['isFunding']
    ?
    Funding('${element['ele']??'NA'}',
   ))
    .toList(),
    )

2

Answers


  1. You can achive it by using function to get some widget E.g.

    ... 
    child: _myFancyWidget(),
    ... 
    Widget _myFancyWidget() {
       checkFund();
       return  Wrap( ... );
    }
    ...
    void checkFund(){}
    ...
    
    Login or Signup to reply.
  2. You can turn expression body => into a block body

    void checkFund(){}
    
        Wrap(
        children: entList
            .map((element) { 
             checkFund();
              retrun Padding(
        
        padding: const EdgeInsets.only(left: 4.0, bottom: 5),
        
        child: element['isAcq']
        ? Acquisition('${element['ele']}')
        : element['isPartner']
        ? GestureDetector(
        // onTap: () {
        //   print('partner');
        // },
        child: NewPartnerShip(
        '${element['ele']}',
       )
        : element['isFunding']
        ?
        Funding('${element['ele']??'NA'}',
       ))
        .toList(),
        );
                           }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search