Home > Software design >  The element type 'Future<void>' can't be assigned to the list type 'Widget
The element type 'Future<void>' can't be assigned to the list type 'Widget

Time:11-30

builder: (context, state) {
          if(state.status == RecievingState.success && state.userData != null){
            return  Column(
            children: [  Vibration.vibrate(); //error
            ],)
            },
            }

as soon as the data is changed from API. I want the phone to vibrate within same page...

CodePudding user response:

If you like vibrate every time the if condition get satisfied, you can do :

builder: (context, state) {
     if(state.status == RecievingState.success && state.userData != null){
        Vibration.vibrate();
        return  Column(
          children: [  

You can add another bool to control the vibrate on the build method.

If you like to check the state, Use FutureBuilder.

CodePudding user response:

Column children should be widget only like this

Column(
children: <Widget>[
const Text('hello'),
const Text('world'),
] )

if you want to use vibrate please refer

  • Related