https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
compose
  • h

    hfhbd

    02/09/2022, 8:09 PM
    What are the (hidden) costs regarding performance of
    CompositionLocalProvider
    ? https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#CompositionLocalProvider(kotlin.Array,kotlin.Function0)
    z
    r
    • 3
    • 14
  • j

    Jeff Jackson

    02/09/2022, 9:04 PM
    Is there an easy way to display a collection of
    DropdownMenuItem
    s where one has a selection state (check mark)?
    c
    • 2
    • 9
  • b

    brabo-hi

    02/09/2022, 9:36 PM
    Want to re-ask this question
    r
    c
    • 3
    • 3
  • c

    Chris Johnson

    02/09/2022, 11:04 PM
    I have a question about LazyColumn/Row. Does it still recycle/remember composables that scroll off screen? Or does it just create a new composable everytime a new one comes into view? I assume there has to be some sort of caching going on since you can put
    remember { X }
    inside LazyColumn/Row items and the next time you scroll to that item it remembers that state. Or maybe I've gotten lucky in that and there's a cache amount that I haven't scrolled past yet.
    a
    • 2
    • 6
  • z

    Zoltan Demant

    02/10/2022, 5:22 AM
    Started seeing a
    No static method stickyHeader$default
    after upgrading to
    1.2.0-alpha03
    . Seems to only affect my design systems module, e.g. I can place a
    LazyColumn
    with stickyHeaders in other modules just fine. Proguard is temporarily disabled, and my dependencies are exactly identical between the modules. Any other clues as to what I should look for (Ive tried invalidate caches + clean)?
    • 1
    • 1
  • g

    Gerardo Ernesto Rodriguez Navar

    02/10/2022, 6:31 AM
    On compose 1.1.0 tests are not running 😞
    c
    • 2
    • 9
  • o

    OG

    02/10/2022, 8:13 AM
    Just reposting this I asked a couple days ago in hopes that maybe some folks with ideas had missed it... 🙈🙊🙉 https://kotlinlang.slack.com/archives/CJLTWPH7S/p1644267546408289?thread_ts=1644267546.408289&cid=CJLTWPH7S
    🔥 1
    z
    • 2
    • 2
  • g

    galex

    02/10/2022, 8:36 AM
    Can I render a
    @Composable
    outside of
    setContent {}
    so that I could get the size of one child
    Composable
    within? I don’t care doing that in the UI thread right now, just want to know if it’s possible!
    s
    a
    • 3
    • 39
  • t

    Tolriq

    02/10/2022, 9:43 AM
    Not fully Compose specific but is there a way to easily detect no more needed Opt-In like ExperimentalMaterialApi ?
    j
    • 2
    • 2
  • a

    Arpit Shukla

    02/10/2022, 10:47 AM
    Can someone point me to the issue in issue tracker where even after pressing and holding the delete button, while using numeric keyboard with a TextField, digits are only removed one at a time?
    s
    • 2
    • 3
  • t

    Tim Malseed

    02/10/2022, 12:34 PM
    Is there any official word on efforts to improve preview rendering times? It seems to be a pain point for many developers, especially when getting started with Compose. I'm happy to patiently wait for improvements, and I'm sure this is a priority, but it would be nice to be able to point my colleagues to a plan or roadmap, something tangible that indicates that we can expect improvements in this area. I'd also love to hear from the Jetpack team what it is exactly that contributes to slow preview rendering times, and what challenges they face in improving this.
    c
    s
    • 3
    • 6
  • t

    Trym Nilsen

    02/10/2022, 2:16 PM
    Is there a way to initially select all the text in a
    SelectionContainer { Text(...) }
    right now it only selects the word that was pressed.
    s
    • 2
    • 1
  • m

    martinsumera

    02/10/2022, 3:22 PM
    I'm trying to implement something like a fillViewPort functionality for scrollable content. Basically, I want the content to fill the remaining size of the screen when the content is not bigger than the screen, but I want to be able to scroll when the content is bigger, Does anyone know how to solve this issue?
    c
    • 2
    • 2
  • n

    Nathaniel Rowe

    02/10/2022, 4:58 PM
    I'm getting a
    ViewModel has no zero argument constructor
    error when trying to construct a hilt view model in a compose function. Anyone else experiencing this? I'm not using the jetpack navigation component, just trying to inject a view model scoped to LocalViewModelStoreOwner.current. I get this error when trying to inject even a simple class with no sub-dependencies. My view model is provided like this:
    viewModel: MyViewModel = viewModel()
    , and I'm using the @HiltViewModel annotation on my view model. My activity and application all support hilt injection properly. I'm using the "androidx.lifecycle:lifecycle-viewmodel-compose" dependency for creating my view model. Let me know if you need more information. Edit: this also only happens when trying to create the view model with any injected dependencies. If the view model has no dependencies, it works fine. The
    hiltViewModel()
    is only supposed to be used with the navigation component, which I am not using. I am using an alternate navigation library (this one: https://github.com/olshevski/compose-navigation-reimagined), but from my understanding, it sets the LocalViewModelStoreOwner properly, and that's what the
    viewModel()
    function uses. I'm assuming it's something to do with the view model factory.
    c
    a
    • 3
    • 16
  • r

    Rajashekar

    02/10/2022, 5:30 PM
    I'm trying to achieve this design with compose. I want to open dialpad with number input keyboard, this action triggers once I click FAB icon. I do not have TextField so cannot call the keyboard by default, in my case keyboard should open clicking on FAB. I have tried few things, but keyboard won't show up, any clue?
    Scaffold(
        floatingActionButton = {
            FloatingDialButton(
                keyboardController,
                focusRequester
            )
        },
        modifier = Modifier.focusRequester(focusRequester)
    ) {
        ScreenContent(uiState)
    }
    @Composable
    fun FloatingDialButton(
        keyboardController: SoftwareKeyboardController?,
        focusRequester: FocusRequester,
    ) {
        FloatingActionButton(
            onClick = {
                focusRequester.requestFocus()
                keyboardController?.show()
            },
        ) {
            Icon(
                painterResource(id = R.drawable.ic_dialpad),
                contentDescription = "",
                tint = MaterialTheme.colors.onSecondary
            )
        }
    }
    d
    • 2
    • 1
  • m

    Matthew Laser

    02/10/2022, 5:44 PM
    Can I get a sanity check as to why my UI won’t recompose? I’ve got a simple 1 activity setup with corresponding
    ViewModel
    , along with a
    data class MyUIState
    . I’m initializing my property as such:
    var uiState by mutableStateOf(MyUiState.empty)
    . , where
    empty
    is just a default initializer with default values. I’m then updating individual properties of
    uiState
    as events happen, for instance
    uiState.loading = true
    The `ViewModel`s is passed into my composable
    MyScreen
    as such from
    MyActivity
    setContent { MyScreen(viewModel) }
    Finally, inside of my composable
    MyScreen
    I'm doing
    val uiState = viewModel.uiState
    and driving changes off of those values, for instance
    if (uiState.loading)
    - however, this is the point at which they aren't recomposed. Most of the examples I can find use a very simple value like
    mutableStateOf(true)
    , so I'm assuming there is something going on where just updating a property isn't having the right effect.
    c
    r
    • 3
    • 20
  • a

    Alderson Elliot

    02/10/2022, 6:52 PM
    Can I put the result of rememberNavController() into the ViewModel for route persistence?
    i
    • 2
    • 1
  • a

    Alderson Elliot

    02/10/2022, 7:17 PM
    Are there any articles on good navigation design like this(https://compose.academy/blog/modular_navigation_with_jetpack_compose)
    f
    v
    • 3
    • 3
  • v

    Vahalaru

    02/11/2022, 12:39 AM
    What is the difference or what would the reasoning be behind using rememberScaffoldState as a peramitor instead of in the function itself. Such as... @Composable fun MyScreen( state: UiState<List<Movie>>, scaffoldState: ScaffoldState = rememberScaffoldState() ) { // Instead of // val scaffoldState = rememberScaffoldState() // If the UI state contains an error, show snackbar if (state.hasError) { //
    LaunchedEffect
    will cancel and re-launch if //
    scaffoldState.snackbarHostState
    changes LaunchedEffect(scaffoldState.snackbarHostState) { // Show snackbar using a coroutine, when the coroutine is cancelled the // snackbar will automatically dismiss. This coroutine will cancel whenever //
    state.hasError
    is false, and only start when
    state.hasError
    is true // (due to the above if-check), or if
    scaffoldState.snackbarHostState
    changes. scaffoldState.snackbarHostState.showSnackbar( message = "Error message", actionLabel = "Retry message" ) } } Scaffold(scaffoldState = scaffoldState) { /* ... */ } }
    :thread-please: 1
    k
    • 2
    • 11
  • g

    Guilherme Delgado

    02/11/2022, 12:03 PM
    Hi guys! I’m experiencing a strange behaviour. My ViewModel
    init {}
    it’s called twice. I’m using jetpack compose (1.1.0 and it happened also with 1.1.0-rc01): • ActivityA has ViewModelA and everything is ok. • ActivityB has a
    AnimatedNavHost
    with 3 composable (“screens”). When they’re first created I get this 2 time problem, but after that, when I change between them, the
    init {}
    is called only once as expected. What could it be?
    m
    r
    • 3
    • 9
  • a

    Andrew Leung

    02/11/2022, 5:32 PM
    Hello, I’ve been experiencing some crashes lately when trying to pop a destination that, seemingly from the pattern, contains a nested navigation (either a NavHost or an AnimatedNavHost). It’s almost like when the screen containing the navhost is popped off the stack, it’s attempting to recompose during the time it’s being popped, and throws the following exception:
    java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels after the NavBackStackEntry is destroyed.
            at androidx.navigation.NavBackStackEntry.getViewModelStore(NavBackStackEntry.kt:207)
            at com.google.accompanist.navigation.animation.AnimatedNavHostKt.AnimatedNavHost(AnimatedNavHost.kt:144)
            at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost$11.invoke(Unknown Source:23)
            at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost$11.invoke(Unknown Source:10)
            at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:140)
            at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2158)
            at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2404)
            at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2585)
            at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2571)
            at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:247)
            at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1)
            at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:2571)
            at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:2547)
            at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:620)
            at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:786)
            at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:105)
    This is on latest 2.5.0-alpha01, but was also occurring on 2.4.0-alpha01 (but with a different error message)
    i
    e
    s
    • 4
    • 8
  • m

    Mehdi Haghgoo

    02/11/2022, 5:58 PM
    I think there is a bug with the preview tool in Android Studio Chipmunk 2021.2.1 Beta 2. The preview is not consistent with what you see on the device. The paddings displayed in preview do not reflect the real values given. Here's a screenshot.
    c
    c
    • 3
    • 12
  • e

    Evgeny Taskaev

    02/11/2022, 7:05 PM
    Hello everyone) Tell me, is there some practical example when you need to use requiredSize modifier, but not size modifier. And is requiredSize always worth using when exact dimensions are needed?)
    a
    c
    a
    • 4
    • 7
  • s

    samp

    02/11/2022, 9:08 PM
    Does jetpack compose support view impression callbacks or any pointers that how we can implement a composable item impression callbacks?
    m
    • 2
    • 2
  • l

    Landry Norris

    02/11/2022, 9:31 PM
    I'm writing Compose tests for one of my projects that I recently started. I'm getting an ExceptionInInitializerError that is
    caused by java.lang.RuntimeException: Method allowThreadDiskReads in android.os.StrictMode not mocked
    . I wrote a simple test (in thread), which reproduced the issue. This only started when I added Compose tests.
    a
    • 2
    • 6
  • o

    oday

    02/11/2022, 9:48 PM
    where can I see the matrix of gradle wrapper/ gradle plugin/kotlin version/compose version that will work together ?
    l
    • 2
    • 14
  • j

    james

    02/12/2022, 12:16 AM
    if I want to move keyboard focus to a
    TextField
    once my
    ModalBottomSheet
    is shown, is using the `ModalBottomSheetState`'s
    confirmStateChange
    the correct place to do that, or is there a better place? I understand it can work but it doesn't necessarily feel right.. is there a listener I can use which signals "the modal bottom sheet has finished appearing"?
    ➕ 1
    c
    j
    • 3
    • 8
  • n

    Nathaniel Rowe

    02/12/2022, 4:11 AM
    I'm a situation where I want my view model to communicate a navigation event to the composition after completing some suspending work. For example, user types in a password, hits "login", and then the backend does some long-running work to do all the things necessary for authentication. My concerns are the following: • How to represent the nav event as part of the UI state. Simply setting a state property to "loginComplete = true" means it will be true still when the user navigates back (for whatever reason). • How to reliably cancel the work when the user leaves the composition, but not when the user changes orientations. For example, while the sign-in is happening, the user could press the back button, or navigate into an account recovery screen. If the user does either of these, I want any current sign-in activity to cancel (as opposed to it continuing while the user is off-screen). Navigating back should do this automatically by killing the view model scope, but navigating to the recovery screen doesn't do this. The sign-in can yield theoretically 3 results: normal success, verification required (nav to a verification screen), or sign in failed. While the sign-in is happening, I also want the UI state to be in a loading state. Specifically, my questions are: 1. What is best practice for cancelling any jobs/producers in the view model when navigating from a screen, without doing this on configuration changes and the like. I know of the
    Activity.isChangingConfigurations
    property, but is this reliable? Or should I just make sure to add a call to cancel jobs at every point where a navigation event happens, and make sure no navigation events happen higher up in the composition hierarchy? 2. What is the best practice for the view model communicating a nav event to the composable? I have a single UI state object for each screen, should I include a "nav event" property in the UI state? And how can I ensure this nav event only triggers up to one actual navigation event? I was thinking of creating an object which is like a "OneShotEvent" object, which has a "consume" method that suspends, and only consumes events that weren't already consumed. Or would a SharedFlow with no replay cache, or some application of producer channels be more idiomatic?
    c
    • 2
    • 4
  • j

    james

    02/12/2022, 11:11 AM
    ☝️ interestingly, this behavior does not happen if I set my modal bottom sheet to
    HalfExpanded
    . if I only open it half way, show the keyboard, then hide the keyboard, nothing strange happens.. but if I open it to
    Expanded
    , then as soon as I hide that keyboard, it re-animates back onto screen 🤯
    z
    • 2
    • 1
  • t

    Tolriq

    02/12/2022, 12:24 PM
    Is there a way to show LinearProgressIndicator in dialogs? I have 0 control over the size.
    • 1
    • 1
Powered by Linen
Title
t

Tolriq

02/12/2022, 12:24 PM
Is there a way to show LinearProgressIndicator in dialogs? I have 0 control over the size.
Arf got bite again by the non clipping. Pass a progress > 1f and the progress will goes off it's parent limits or anything.
View count: 10