title: IllegalStateException: CompositionLocal LocalConfiguration not present Android
body: <p>I'm trying to use <code>staticCompositionLocalOf</code> in Jetpack Compose according to this <a href="https://gustav-karlsson.medium.com/extending-the-jetpack-compose-material-theme-with-more-colors-e1b849390d50" rel="nofollow noreferrer">article on Medium</a>.
  This is my ProvidableCompositionLocal</p>
  <pre class="lang-kotlin prettyprint-override"><code>val lightColors = lightColors(
      primary = LightColor.BackgroundWhite,
      primaryVariant = LightColor.ToolbarWhite,
      secondary = LightColor.FabBlue,
      secondaryVariant = LightColor.BackgroundWhite,
      surface = LightColor.SurfaceWhite,
      onPrimary = LightColor.TextBlack,
      onSecondary = LightColor.TextBlack,
      onSurface = LightColor.TextBlack
  )
  
  val darkColors = darkColors(
      primary = DarkColor.BackgroundBlue,
      primaryVariant = DarkColor.ToolbarBlue,
      secondary = DarkColor.FabGrey,
      secondaryVariant = DarkColor.BackgroundBlue,
      surface = DarkColor.SurfaceBlue,
      onPrimary = Color.White,
      onSecondary = Color.White,
      onSurface = Color.White
  )
  
  private val DarkColorPalette =
      Colors(
          material = darkColors,
          toolbar = DarkColor.ToolbarBlue,
          background = DarkColor.BackgroundBlue,
          surface = DarkColor.SurfaceBlue,
          fab = DarkColor.FabGrey,
          pink = DarkColor.Pink
      )
  
  private val LightColorPalette =
      Colors(
          material = lightColors,
          toolbar = LightColor.ToolbarWhite,
          background = LightColor.BackgroundWhite,
          surface = LightColor.SurfaceWhite,
          fab = LightColor.FabBlue,
          pink = LightColor.Pink
      )
  
  val TheColor: Colors
      @Composable
      @ReadOnlyComposable
      get() = LocalColors.current
  }
  
  val LocalColors = staticCompositionLocalOf { DarkColorPalette }
  </code></pre>
  <p>This is the wrapper around the normal Colors class provided by Compose class. The material variable is the normal Colors class.</p>
  <pre class="lang-kotlin prettyprint-override"><code>data class Colors(
      val material: Colors,
      val toolbar: Color,
      val background: Color,
      val surface: Color,
      val fab: Color,
      val pink: Color
  ) {
      val primary: Color get() = material.primary
      val primaryVariant: Color get() = material.primaryVariant
      val secondary: Color get() = material.secondary
      val secondaryVariant: Color get() = material.secondaryVariant
  //    val background: Color get() = material.background
  //    val surface: Color get() = material.surface
      val error: Color get() = material.error
      val onPrimary: Color get() = material.onPrimary
      val onSecondary: Color get() = material.onSecondary
      val onBackground: Color get() = material.onBackground
      val onSurface: Color get() = material.onSurface
      val onError: Color get() = material.onError
      val isLight: Boolean get() = material.isLight
  }
  </code></pre>
  <p>I have also provided it in my Theme function as shown below. I'm getting the <code>darkTheme</code> from Android DataStore</p>
  <pre class="lang-kotlin prettyprint-override"><code>@Composable
  fun BMICalculatorTheme(
      darkTheme: Boolean,
      content: @Composable () -&gt; Unit
  ) {
      val colors = if (darkTheme) {
          DarkColorPalette
      } else {
          LightColorPalette
      }
  
      CompositionLocalProvider(LocalColors provides colors) {
          MaterialTheme(
              colors = colors.material,
              typography = CabinTypography,
              shapes = Shapes,
              content = content
          )
      }
  }
  </code></pre>
  <p>However, I'm getting the below error but can't find any online resources that can help me fix it. In case any further information is needed, I would be more than happy to clarify. Any help would be highly appreciated.</p>
  <pre><code>IllegalStateException: CompositionLocal LocalConfiguration not present
          at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.noLocalProvidedFor(AndroidCompositionLocals.android.kt:123)
          at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.access$noLocalProvidedFor(AndroidCompositionLocals.android.kt:1)
          at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$LocalConfiguration$1.invoke(AndroidCompositionLocals.android.kt:44)
          at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$LocalConfiguration$1.invoke(AndroidCompositionLocals.android.kt:43)
          at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
          at androidx.compose.runtime.LazyValueHolder.getCurrent(ValueHolders.kt:29)
          at androidx.compose.runtime.LazyValueHolder.getValue(ValueHolders.kt:31)
          at androidx.compose.runtime.ComposerImpl.resolveCompositionLocal(Composer.kt:1895)
          at androidx.compose.runtime.ComposerImpl.consume(Composer.kt:1865)
          at androidx.compose.foundation.DarkTheme_androidKt.isSystemInDarkTheme(DarkTheme.android.kt:52)
          at com.octagon_technologies.bmicalculator.data.ThemeDataStore$isDarkMode$$inlined$map$1$2.emit(Collect.kt:135)
          at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catchImpl$$inlined$collect$1.emit(Collect.kt:134)
          at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollector.kt:15)
          at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(Unknown Source:4)
          at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:77)
          at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:59)
          at androidx.datastore.core.SingleProcessDataStore$data$1$invokeSuspend$$inlined$map$1$2.emit(Collect.kt:139)
          at kotlinx.coroutines.flow.FlowKt__LimitKt$dropWhile$$inlined$unsafeFlow$1$lambda$1.emit(Collect.kt:137)
          at kotlinx.coroutines.flow.StateFlowImpl.collect(StateFlow.kt:348)
          at kotlinx.coroutines.flow.StateFlowImpl$collect$1.invokeSuspend(Unknown Source:12)
          at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
          at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
          at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
          at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
          at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
          at android.os.Handler.handleCallback(Handler.java:790)
          at android.os.Handler.dispatchMessage(Handler.java:99)
  </code></pre>