An assertion Tuesday night by President Trump that ID is required to purchase groceries prompted a cascade of criticism from the media and his adversaries, including the lawyer for adult-film star Stormy Daniels.

During a freewheeling rally in Tampa, Trump was making the case for stricter voter identification laws, a cause that is broadly popular among his conservative base, when he made the false claim about grocery shopping.

“If you go out and you want to buy groceries, you need a picture on a card, you need ID,” Trump said at the event at the Florida State Fairgrounds. “You go out and you want to buy anything, you need ID and you need your picture.”

At a briefing on Wednesday, White House press secretary Sarah Huckabee Sanders said she was “not sure” when Trump last went to a grocery store.

“I’m not sure what that matters either,” she said, adding that people have to present an ID to buy beer and wine at grocery stores.

Michael Avenatti, the lawyer for Daniels, was among the scores of critics who took to Twitter to point that out — and, in his case, put in a plug for a possible 2020 presidential bid to challenge Trump.

“People ask me why I think I can prevail against Mr. Trump,” Avenatti wrote. “I tell them it’s because (1) I’ve bought groceries before and (2) I know you don’t need an ID to buy groceries.”

Daniels is seeking to void an agreement with Trump under which she received $130,000 to stay silent about an alleged affair.

For many, Trump’s claim brought to mind reports of President George H.W. Bush expressing amazement upon seeing a supermarket scanner during his 1992 reelection campaign.

John Dean, the former White House counsel under President Richard Nixon, was among those to draw a comparison between the two episodes.

“George H.W. Bush lost an election for not having any idea how a electronic scanner in a market worked,” Dean wrote on Twitter. “Trump thinks you need photo ID to buy groceries. May his ignorance come back to defeat him, not to mention his ignorance is 10,000 times Bush’s!”

Kaili Joy Gray, the managing editor of the liberal website Shareblue, also sought to portray Trump as out of touch.

“This man has never bought a carton of milk in his life, has he?” she asked on Twitter.

Media covering Trump’s rally were among the first to pounce on Tuesday night as the president rallied the faithful and promoted the Florida gubernatorial candidacy of Rep. Ron DeSantis (R-Fla.).

“Honest question: What’s the last time he’s bought groceries?” wrote Zeke Miller, a White House reporter for the Associated Press.

Jim Acosta of CNN, a frequent target of criticism by Trump, also weighed in with a tweet, writing: “Trump out of touch here . . . you don’t need an ID to buy groceries.”