Stay organized with collections
Save and categorize content based on your preferences.
Suggest improvements to follow Compose layout best practices.
Please analyze the Compose layout below and suggest improvements to ensure it is performance and is aligned with best practices.
Suggest specific optimizations, including but not limited to:
- State Hoisting: Move state up to the lowest common ancestor that needs access to it. This improves testability and makes components more reusable.
- Unidirectional Data Flow: Data flows down, events flow up. This makes debugging and reasoning about your UI easier. Use remember to store state, and pass lambdas for events.
- Immutable Data: Use data classes and Immutable annotations where possible. This helps Compose optimize recompositions.
- Using 'remember' to cache results, but only for values that should survive recompositions (as this could cause a memory leak)
- Using the 'key' parameter in lazy layouts to avoid unnecessary recompositions
- Using 'derivedStateOf' for rapidly changing states
- Avoiding backwards writes, changing state after it has been in a composable ot prevent recomposition loops
- Ensuring breaking down UI into smaller composables that do one thing well
- Proper state management, hoisting state to parent comptables and using lifecycle-aware coroutine scopes like 'viewModelScope' or 'lifecycleScope' for async operations
- Adhering to Jetpack Compose API guidelines for naming, layering components, and ensuring accessibility
- Using Baseline Profiles and R8 optimizations
- Passing a 'Modifier' parameter in composables to allow customization and maintain consistency
- Not excessively overusing modifiers, resulting in reduced readability and clutter
- Unnecessary use of WebView inside of Comparables
Please only tell me where my code can be improved. Do not mention areas where my code is already compliant with best practices.
Do not write code in your initial response. Instead, ask the developer whether they would like you to attempt to make some of these changes first.
$CURRENT_FILE
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-08 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-08 UTC."],[],[],null,["# Analyze Compose layout\n\nSuggest improvements to follow Compose layout best practices.\n\n*** ** * ** ***\n\n Please analyze the Compose layout below and suggest improvements to ensure it is performance and is aligned with best practices.\n\n Suggest specific optimizations, including but not limited to:\n\n\n - State Hoisting: Move state up to the lowest common ancestor that needs access to it. This improves testability and makes components more reusable.\n - Unidirectional Data Flow: Data flows down, events flow up. This makes debugging and reasoning about your UI easier. Use remember to store state, and pass lambdas for events.\n - Immutable Data: Use data classes and Immutable annotations where possible. This helps Compose optimize recompositions.\n - Using 'remember' to cache results, but only for values that should survive recompositions (as this could cause a memory leak)\n - Using the 'key' parameter in lazy layouts to avoid unnecessary recompositions\n - Using 'derivedStateOf' for rapidly changing states\n - Avoiding backwards writes, changing state after it has been in a composable ot prevent recomposition loops\n - Ensuring breaking down UI into smaller composables that do one thing well\n - Proper state management, hoisting state to parent comptables and using lifecycle-aware coroutine scopes like 'viewModelScope' or 'lifecycleScope' for async operations\n - Adhering to Jetpack Compose API guidelines for naming, layering components, and ensuring accessibility\n - Using Baseline Profiles and R8 optimizations\n - Passing a 'Modifier' parameter in composables to allow customization and maintain consistency\n - Not excessively overusing modifiers, resulting in reduced readability and clutter\n - Unnecessary use of WebView inside of Comparables\n\n Please only tell me where my code can be improved. Do not mention areas where my code is already compliant with best practices.\n\n Do not write code in your initial response. Instead, ask the developer whether they would like you to attempt to make some of these changes first.\n\n $CURRENT_FILE\n\n\n| To run this prompt in Android Studio, click **Gemini** in the sidebar and paste it in the chat field. \n| To save and retrieve prompts in the Studio IDE, go to **Settings \\\u003e Gemini \\\u003e Prompt Library**.\n\n*** ** * ** ***"]]