Without a doubt, gasoline is more dangerous than diesel, but the risks can be mitigated.
With a well designed and maintained boat, I'd say the difference in risk between gasoline & diesel power is very minimal.
If the boat is very poorly designed and maintained, a gasoline inboard could be a nightmare.
ABYC regs and require blowers, bilge pumps, etc to be designed in a manner so it will not ignite gasoline vapour.
Here's an example:
https://law.resource.org/pub/us/cfr/....H-22.1986.pdf
They are designed that way, but if not properly installed or maintained, they may not stay that way.
Moral of the story - if gasoline powered, take extra good care of your boat.