Edited to replace the word "measure" with a better concept.
間 refers to the time space between two points; speaker feels he has the ability to determine a start and end point at the moment of making the statement. (間 has explicit time boundary)
内 however refers to "time space within"; for when it is difficult for the speaker to determine a start and end point. It refers to the general time during which an event/state is occuring. (No explicit time boundary for 内)
That is why it seems strange to say (though not totally unacceptable):
But is okay to say:
Because one cannot assess the start and end point of the duration within "not rain"
In your example
先生が見てない(間に/内に)逃げよう, the time during "teacher is not looking" isn't a predictable or planned event (No explicit time boundary). Therefore
内に would be more appropriate for your example sentence.
Edited: To try to explain the apparent contradiction with Tsuyoshi's example using
It should have something to do with the speaker's expectation of future circumstances:
The speaker takes the default standpoint of "clear weather" as a default weather.
We normally do not worry "when the duration of
[clear weather] ends". But rather we would think in the manner of "when does
[other weather] begin?". It becomes unimportant to assess a start and end point for a default standpoint. Since it's a default standpoint, both 間 and 内 can be used and will not sound unnatural or not smooth.
[other weather] there is a start and end point, but the speaker expects
[other weather] (e.g. rainy) to behave in a way that he cannot determine a start and end point for it.
Now for the case of
"teacher is not looking", the speaker takes the default standpoint of
"teacher is always paying attention" because that is how he would expect the teacher to behave. The alternative: duration of
"teacher is not looking" becomes hard for the speaker to determine a start and end point.
-  Makino, S., & Tsutsui, M. (2010). A dictionary of basic Japanese grammar. pg. 512-515 entry for uchi ni