Yes, in general, with a normal airplane of a standard configuration type (Cessna 100 for example), you can clear a TYPICAL obstacle a little shorter by using flaps. By typical I mean an FAA spec 50 foot tree at the end of a short runway.
If your obstacle is a tall mountain quite a ways away from the runway, then it often becomes a function of whether your airplane has the power to sustain a "best angle" climb for that long before overheating, or the drag buildup of a given flap setting catches up with the engine thrust (A tired old 150 will have a fair amount of trouble with that, and a PPONK'ed 180 will do a lot better).
So on a lot of airplanes, in my opinion there are two "best angle" scenarios.
Sustained best angle is usually quoted as no flaps, and is a repeatable, flight-test-able, define-able, teach-able condition, that takes drag buildup and cooling into consideration.
Initial best angle, which is much more relevant to most "obstacle" takeoffs where you are clearing something close to the runway, is usually a lot better using flaps. The takeoff from start until first 20 or 30 seconds after liftoff can benefit from flaps much more, because you can usually get up and over the obstacle before the drag really catches up to the thrust, and by then you can retract the flaps and/or lower the nose to accelerate to best rate. This is why you often see 150's and 172's leaping off the ground for a few moments and then the climb slows down once they reach 100 feet.
Now the reality of this is that you can also make measurable gains by using one flap/takeoff technique over another, ESPECIALLY where obstacles and short strips are concerned. But I can hear some of the natives getting restless already, and I'll have to wait for an invitation to discuss that further
