Appium Flutter Driver Can not take screenshoots

I use webdriverio nodejs with the cucumber framework, if it is passed it succeeds in taking a screenshot but if it fails it cannot take a screenshot,

afterStep:  async function (test, scenario, { error, duration, passed }, context) {
        if (error) {
          await browser.takeScreenshot();
        }
        else{
          await browser.pause(2000);
          await browser.takeScreenshot();
        }
    },

i expecting if failed success take screenshoot