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
  • z

    Zoltan Demant

    08/03/2022, 3:13 PM
    *Im rendering a tree of nodes with compose, and I have a hard time understanding if caching can happen for scenarios like this?* Each node has a
    @Composable
    function that produces a T. For a simple branch with nodes A > B > C; I end up with a scenario where if any of the nodes change, all of them have to produce a new T. Ideally, only affected nodes should reproduce their T, so if B changes, C can remain the same. Any ideas? More details in 🧵
    • 1
    • 1
  • c

    Colton Idle

    08/03/2022, 7:36 PM
    android studio c9 out today https://androidstudio.googleblog.com/2022/08/android-studio-electric-eel-canary-9.html idk what this means just yet, but hopefully it means no flashing/resetting of nav graph when making a change.
    Starting with Electric Eel Canary 9, if your project is using Compose version 1.2 or higher, Live Edit no longer needs to reset composition after code changes. Only the first code change made to a given file resets composition. Subsequent edits don't reset composition.
    l
    a
    d
    • 4
    • 9
  • r

    Roudy Korkis Kanaan

    08/04/2022, 1:24 AM
    Hey everyone, I'm trying out the
    rememberTransformableState
    for panning/zooming but it's not working as the sample suggests. I copied the sample found here. Zooming and rotating works but
    offsetChange
    is always zero
    j
    l
    • 3
    • 4
  • t

    Tin Tran

    08/04/2022, 2:19 AM
    I also get this SEGSEGV with webview inside a bottom sheet when I upgrade to 1.3.0-beta02. Reverting back to 1.2.0 fixed the issue
    d
    • 2
    • 1
  • n

    nuhkoca

    08/04/2022, 8:29 AM
    Hello, I set a different background color when a list item is clicked. However when its position changes, a different one gets that background color as the previous item’s position had changed. How do I find a more reliable index then?
    Box(modifier = Modifier.animateItemPlacement()) {
        InstrumentView(instrument = item, selected = selectedIndex == i) {
            selectedIndex = if (selectedIndex != i) i else -1
        }
    }
    p
    • 2
    • 1
  • k

    K Merle

    08/04/2022, 9:21 AM
    Anyone have an example of how to share viewmodel between screens? I'm getting
    java.lang.IllegalArgumentException: No destination with route..
  • t

    Tin Tran

    08/04/2022, 9:32 AM
    Is there away to disable fling behavior on accompanist pager?
    c
    • 2
    • 2
  • t

    Tepes Lucian Victor

    08/04/2022, 10:31 AM
    Is there a
    SlidingPaneLayout
    echivalent in compose?
  • v

    Vaios Tsitsonis

    08/04/2022, 11:48 AM
    Hello! I have a clickable
    Row
    . It's shape has radius. I ve added
    clickable
    modifier and the ripple effect does not respect the shape... How I can implement the desired behavior (apart from wrapping my composable with
    Card
    :P)
    y
    l
    c
    • 4
    • 21
  • d

    dave08

    08/04/2022, 11:57 AM
    Hi! Just wondering if migrating an app to compose piece by piece still has major performance issues, or was that already resolved?
    s
    • 2
    • 4
  • s

    Slackbot

    08/04/2022, 2:21 PM
    This message was deleted.
  • l

    Lukasz Kalnik

    08/04/2022, 2:51 PM
    What is the purpose of the
    content
    in
    ModalBottomSheetLayout
    when
    sheetContent
    takes all the contents of the bottom sheet? What if I want to display this modal bottom sheet over different screens, should I just then leave
    content
    empty?
    c
    y
    • 3
    • 3
  • a

    Altynbek Nurtaza

    08/04/2022, 7:55 PM
    i’m using intel macbook. the problem also occured on my friend’s m1 macbook, but it works on his windows machine
    c
    c
    +2
    • 5
    • 19
  • p

    Paul

    08/04/2022, 9:19 PM
    Hey all. Recently I've migrated my open-source app called Gamedge to be a pure Jetpack Compose app. It utilizes all the latest libraries & tools in the Android development world. A couple of thoughts: 🧵 https://github.com/mars885/gamedge
    d
    • 2
    • 6
  • k

    K Merle

    08/05/2022, 5:35 AM
    I am trying to have nested
    NavHost
    , and
    navigation
    DSL is kind of is not optimal. Having actual
    NavHost
    nested in parent
    NavHost
    would give me more control over background shared element of nested screens. Is having
    NavHost
    nested not recommended?
  • k

    ken_kentan

    08/05/2022, 9:00 AM
    Hi! Is it possible to implement dialog with transparent background by using
    NavGraphBuilder.dialog
    ?
    i
    • 2
    • 1
  • f

    Filip Wiesner

    08/05/2022, 9:29 AM
    That is a very broad question. Have you read the Compose performance doc?
    d
    i
    +4
    • 7
    • 14
  • k

    KotlinLeaner

    08/05/2022, 10:39 AM
    Hello ✌️, I have Font
    Font(R.font.source_sans_variable_350)
    and I am passing
    FontWeight
    so what would be? I checked
    FontWeight.Light
    and
    FontWeight.Normal
    which is 300 and 400 respectively. So is there any solution for this ?
    • 1
    • 3
  • l

    Lukasz Kalnik

    08/05/2022, 12:49 PM
    I have a
    ModalBottomSheetLayout
    where the contents is the main screen with a list of items, and the
    sheetContent
    are item details (with different settings). As the item details are quite complex, and don't influence the main screen, I would like to have them in a separate ViewModel. How can I pass the
    itemId
    from the
    MainScreenViewModel
    to the
    ItemDetailsViewModel
    . I don't really fancy creating a shared ViewModel just to pass one value (which is anyway only temporary, as the
    ItemDetailsViewModel
    will store
    itemId
    as well to get the item data).
    m
    • 2
    • 2
  • n

    Nat Strangerweather

    08/05/2022, 2:35 PM
    Hi, I am getting an indexOutOfBoundsException when I initially install my app on a fresh emulator. Is there something really obvious in my code snippet that would cause this to happen? 🧵
    l
    l
    • 3
    • 114
  • g

    George

    08/05/2022, 7:17 PM
    Compose + ViewModel + MutableState combination is error-prone due to snapshots mechanics. Shouldn't something be done about it? (details inside)
    d
    z
    +2
    • 5
    • 28
  • t

    Tlaster

    08/06/2022, 4:59 AM
    Is there any way to generate Material 3 ColorScheme from a single color like
    ColorScheme.fromSeed
    in flutter?
    r
    • 2
    • 1
  • z

    Zoltan Demant

    08/06/2022, 8:17 AM
    This seems impossible from my understanding of how compose works, but is it somehow possible? Im creating a class A that holds B, if B is passed in as State<B> then I can "move" the recomposition scope further in; but if B is read and passed into A as the value itself, then the recomposition scope wraps the entire thing and A is recomposed together with B. Can I somehow pass B "as the value" but still push the recomposition scope further in? :kotlin-intensifies:
    s
    s
    • 3
    • 11
  • g

    gsala

    08/06/2022, 8:43 AM
    Hi. Is there an equivalent of TextView’s breakStrategy for the
    Text
    or
    BasicText
    Composables? I’m trying to get a
    balanced
    break strategy where the line lengths are similar.
    z
    a
    • 3
    • 3
  • d

    dimsuz

    08/06/2022, 11:16 AM
    If I write a custom layout and use a
    State
    value to affect placement of layout children, will it impact performance in some way? Is there some in-depth look of what is cached and when during layout in compose? E.g.
    fun MyLayout(x: Int) {
      Layout(content = {...}) { m, c -> 
         ...
         layout(w,h) { child.placeRelative(x, 0) }
      }
    }
    
    fun Screen() {
      // or x is from pointerInput + stored in State
      val x by animateValue(300)
      MyLayout(x)
    }
    s
    z
    • 3
    • 3
  • c

    CLOVIS

    08/06/2022, 1:54 PM
    There was a very good 4-5 parts series on Medium about the inside working of Snapshot and everything. I can't find it anymore, does anyone have the link to it?
    s
    • 2
    • 2
  • n

    nuhkoca

    08/06/2022, 11:40 PM
    Hello, trying to use Accompanist Horizontal Pager with Bottom Sheet but the tab part of the screen is not dimming as I use bottom sheet inside pages. I don’t want to use the BottomSheet in holder Compose view because it’d be too much hassle for handling click events, passing correct list of items etc. How do I dim the rest of the screen properly or what would be the more efficient way to integrate BottomSheet while using Pager if each tab required bottom sheet?
    f
    o
    • 3
    • 4
  • c

    Colton Idle

    08/07/2022, 2:56 AM
    If I have a screen that displays a list of Books and I want to update the "likes" on each individual book while the screen is showing, but I also want to update the list of Books showing on the screen. What's the best route to go? Option 1: var books = mutableStateListOf<Book>() class Book(title: String, likes: Long) Option 2: var book = listOf<Book>() class Book(title: String, likes: Long){ var likes by mutableStateOf() } Option 3 var books = mutableStateListOf<Book>() class Book(title: String, likes: Long){ var likes by mutableStateOf() }
    f
    • 2
    • 12
  • d

    dimsuz

    08/07/2022, 12:46 PM
    I have a
    Box
    and I want to use
    pointerInput
    to detect drag gestures inside this box, but I want to ignore cases when drag starts in the smaller child in center of that box. For example box is 400x400.dp and I want to ignore drags coming from within 100x100.dp of its centered child. How can I achieve this? Use
    onGlobalLayout
    to capture the position and size of the child and then in
    onDrag
    check if
    change: PointerInputChange
    comes from a child area and do not do what I usually do there in this case?
    m
    z
    • 3
    • 7
  • a

    Alexander Maryanovsky

    08/07/2022, 2:43 PM
    I have a
    Column
    of
    Item
    , for example like this:
    A2
    C1
    B2
    with something like
    @Composable
    fun Item(letter: Char, index: Int){ ... }
    Now each item belongs to a group, specified by the letter (A, B, C etc.) and has an index, specified by the number. The user can 1. Change the item’s index by selecting the item and pressing left/right. So, selecting “A2”, for example, and pressing right, changes the item to “A3". When this happens, I’m animating the
    Text
    using
    AnimatedContent
    so the “A3” slides in from the right and the “A2" slides out to the left. The animation runs when the new index is adjacent to the previous index. 2. Remove an item by selecting it and pressing “delete”. Now, I have a problem. If the list is, for example
    A1
    A2
    ...
    and the user deletes A1, the animation runs because as far as the 1st call to
    Item
    is concerned, what happened was the index `remember`ed by
    AnimatedContent
    changed from ‘1’ to ‘2’. I would like to not have the animation run in this case. If I
    key
    the
    Item
    with
    index
    then the animation doesn’t run even when it should.
    a
    • 2
    • 4
Powered by Linen
Title
a

Alexander Maryanovsky

08/07/2022, 2:43 PM
I have a
Column
of
Item
, for example like this:
A2
C1
B2
with something like
@Composable
fun Item(letter: Char, index: Int){ ... }
Now each item belongs to a group, specified by the letter (A, B, C etc.) and has an index, specified by the number. The user can 1. Change the item’s index by selecting the item and pressing left/right. So, selecting “A2”, for example, and pressing right, changes the item to “A3". When this happens, I’m animating the
Text
using
AnimatedContent
so the “A3” slides in from the right and the “A2" slides out to the left. The animation runs when the new index is adjacent to the previous index. 2. Remove an item by selecting it and pressing “delete”. Now, I have a problem. If the list is, for example
A1
A2
...
and the user deletes A1, the animation runs because as far as the 1st call to
Item
is concerned, what happened was the index `remember`ed by
AnimatedContent
changed from ‘1’ to ‘2’. I would like to not have the animation run in this case. If I
key
the
Item
with
index
then the animation doesn’t run even when it should.
a

Alex Vanyo

08/08/2022, 4:22 PM
Using
key
is definitely the right track, but you will probably need to create some sort of unique id to use as the
key
to specify which items are “the same” that are being modified or deleted. Here’s another way to look at it: Let’s say I gave you this list before, and this list after. Before:
A1
A2
A3
...
After:
A2
A3
A4
...
Just from looking at those two lists, there’s two possibilities: Either
A1
was deleted, or all of the items were incremented. But just by looking at the before and after, there’s no way to know which happened, and that before and after view is all Compose knows as well. There needs to be some additional information used for tracking what happened.
a

Alexander Maryanovsky

08/08/2022, 4:34 PM
Yes, unfortunately that's exactly the problem. The initial and final states are the same. Only the user action that triggered the change is different.
a

Alex Vanyo

08/08/2022, 4:38 PM
Right, the information you have right now isn’t enough. I’d try doing something like keeping a
UUID.randomUUID()
around with your items, and using that as your
key
. Removing an item would cause a
UUID
to be deleted, whereas updating an item would keep the old
UUID
, but with a new value.
a

Alexander Maryanovsky

08/08/2022, 4:59 PM
That's going to be tough. The item list is the result on an external computation that exposes it via StateFlows.
View count: 12