A drug dealer who died after swallowing a packet of cocaine during a police raid had been shouted at up to 30 times to spit it out, a fatal accident inquiry has been told.

Stuart Sandeman was seen popping a "fairly large" bag of white powder into his mouth and chewing as officers urged him not to swallow the Class A drug.

The inquiry at Perth Sheriff Court was told that Sandeman, a convicted cocaine dealer, was pronounced dead within 45 minutes of the police raid starting at his hom on May 6 2011.

Detective Constable Gillian Donnelly told the inquiry: "I've obviously thought about it since the incident happened and I don't think there's anything we could have done differently."

She said she had gone to cover the rear of the flat in Struan Road, Perth, as colleagues used a battering ram to smash down the front door and gain access to Sandeman's home.

DC Donnelly said she was climbing in through the window when she saw Sandeman in the kitchen, appearing to pop a package of drugs into his mouth.

"When I'm climbing in the window I'm shouting 'it's the police' and to open the door. When he places the package into his mouth I'm saying to spit it out.

"I tried to grab his hands and restrain him. However, due to his size and weight he continued walking away from me. The item I had seen to be put in his mouth I believed to be controlled drugs.

"For anybody to put controlled drugs into their mouth is going to cause a safety issue to them. If they swallow them and they burst inside the person that is going to be a danger to them."

The inquiry, which before Sheriff Fiona Tait continues.