Heat oil in a large skillet over medium heat. Add shallots and garlic and cook, stirring, until fragrant and beginning to soften, about 1 minute. Add the mushrooms and cook, stirring often, until they release their liquid and the pan is almost dry, 10 to 12 minutes. Add chard (or spinach) and continue to cook, stirring, until wilted, about 4 minutes. Whisk broth and flour in a small bowl. Add to the pan along with the remaining 1/4 teaspoon salt, pepper and rosemary. Cook, stirring, until the mixture bubbles and thickens, about 1 minute.