Help, how to update arraylist in jetpack compose

I’m stuck trying to understand how to get a variable initialised, and later updated, in kotlin to update in Jetpack Compose and cause a composition that uses it to recompose. The variable is an arraylist of bitmaps set up like so (all of this works fine so I have not included the getOutputDirectory() and imageReaderNew() functions):
// set up an empty bitmaps arraylist
// should I be using mutableListOf() here? if so how?
var bitmaps: ArrayList<Bitmap> = ArrayList()
// get the uri of the folder to save images to
val outputDirectory = getOutputDirectory()
// read in a list of images in the images folder
var fileList: ArrayList<File> = imageReaderNew(outputDirectory)
// get a list of bitmaps of the images
bitmaps = getBitmapList(fileList)
When I initialise my composition I do this:
BottomSheetScaffold(
scaffoldState = scaffoldState,
sheetPeekHeight = 0.dp,
sheetContent = {
PhotoBottomSheetContent(
bitmaps = bitmaps,
//should I be using remember here?
//bitmaps = remember { bitmaps },
modifier = Modifier.fillMaxWidth()
)
}
)
{ }
Finally, in my composable I do this:
fun PhotoBottomSheetContent(
bitmaps: List<Bitmap>,
// should I be using mutableListOf() or remember { } here? again if so how?
modifier: Modifier = Modifier
)
{
}
Popular Android topics










Other popular topics










Latest in Android
Latest (all)
Categories:
My Saved Portals
-
None saved yet
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /v
- /react-native
- /wasm
- /security
- /django
- /nodejs
- /centos
- /haskell
- /rails
- /fable
- /gleam
- /swift
- /js
- /deno
- /assemblyscript
- /tailwind
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /preact
- /flutter
- /c-plus-plus
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /nim
- /vuejs
- /emacs
- /elm
- /nerves