I would like to repeat a very important aspect of flash photography here, namely the following.
The background brightness, when there is any background light, depends on the shutter speed of your photo. Yes, also on the aperture and ISO, but these latter two also affect the flash brightness (assuming your flash power is constant).
This means the following.
If I want to mix in background light, I use a slower shutter.
Consider these two photos, both taken with a flash aiming straight into the student’s face (not great technique, but it was to demonstrate this fact), and at 400 ISO and f/5.6.
Picture 1 is at 1/60th second – and note, usually your simple modes like P and the scene modes, will restrict you to that speed or faster:
Typical “brrr, flash” picture.
The second shot was taken at exactly the same settings, except with a much slower 1/4 second shutter speed:
Clearly that is slow, but the face is still sharp due to the brief duration of the flash.