従来のAndroidのViewでは、プレビュー中なことは isInEditMode
でわかります。これのCompose版です。
コード
以下でわかります。
val runningInPreview = LocalInspectionMode.current
使い所
GoogleMapは記事を書いている現状で、プレビューが働かないので、代わりのものを表示します。
if (runningInPreview.not()) { GoogleMap() } else { Spacer( modifier = Modifier .fillMaxSize() .background(Color.Blue) ) }