Walgreens has agreed to pay $230 million to settle a case brought by the city of San Francisco over the opioid crisis.