If I set the focus on an OutlineTextField the keyb...
# compose
m
If I set the focus on an OutlineTextField the keyboard doesn't appear because I also need to save a reference to the
SoftwareKeyboardController
passed to
onTextInputStarted
callback and set a
FocusObserver
on the composable
Copy code
val softwareKeyboardController = remember { Ref<SoftwareKeyboardController>() }
val focusRequester = remember { FocusRequester() }
SideEffect {
    // set the focus when the composable enter the composition
    focusRequester.requestFocus()
}
OutlinedTextField(
    onTextInputStarted = { controller -> 
        softwareKeyboardController.value = controller 
    },
    modifier = Modifier
        .focusRequester(focusRequester)
        .focusObserver { state ->
            if (state == FocusState.Active) {
                softwareKeyboardController.value?.showSoftwareKeyboard()
            }
        }
)