When you shine a flashlight in space, the light emitted from the flashlight will continue to travel indefinitely until it encounters an object or is absorbed by a medium. In the vacuum of space, where there is no air or matter to obstruct or scatter the light, it will propagate in a straight line, essentially forever, unless it interacts with something.
Light is an electromagnetic wave, and as such, it does not require a medium to propagate through. This means that in the absence of obstacles, the light emitted from the flashlight will continue to travel at the speed of light until it encounters an object, such as a planet, a spacecraft, or interstellar dust and gas.
If the light encounters an object, it can be reflected, refracted, or absorbed. Some of the light may bounce off the object and change direction, while some may be absorbed by the object and converted into other forms of energy. However, if the light doesn't encounter anything, it will continue to travel indefinitely in a straight line.
It's important to note that even though space is often referred to as a vacuum, it is not entirely empty. It contains very low-density particles, such as gas molecules, dust, and even photons. These particles can scatter or interact with light to some extent, but over vast distances in interstellar space, their impact on the propagation of light is generally negligible.