Skip to content

fix app update details#4238

Merged
mdmohsin7 merged 1 commit intomainfrom
app-update-fix
Jan 15, 2026
Merged

fix app update details#4238
mdmohsin7 merged 1 commit intomainfrom
app-update-fix

Conversation

@mdmohsin7
Copy link
Copy Markdown
Member

No description provided.

@mdmohsin7 mdmohsin7 merged commit 4a2b9ea into main Jan 15, 2026
1 check passed
@mdmohsin7 mdmohsin7 deleted the app-update-fix branch January 15, 2026 13:59
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes an issue with updating app details and refactors the getAppDetails method in AppProvider. The UI change in update_app.dart correctly removes a fixed-height SizedBox that could cause layout overflows. The logic change in app_provider.dart improves the behavior of fetching app details. I've identified a potential crash scenario due to unhandled exceptions during data parsing from the server response and suggested a fix to make the application more robust.

Comment on lines +66 to 75
if (appData != null) {
var freshApp = App.fromJson(appData);
var oldApp = apps.where((element) => element.id == id).firstOrNull;
if (oldApp == null) {
return null;
if (oldApp != null) {
var idx = apps.indexOf(oldApp);
apps[idx] = freshApp;
notifyListeners();
}
var idx = apps.indexOf(oldApp);
apps[idx] = App.fromJson(app);
notifyListeners();
return apps[idx];
return freshApp;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The App.fromJson constructor could throw an exception if the appData from the server is malformed (e.g., missing required fields). This would cause an unhandled exception and potentially crash the app. It's safer to wrap the parsing and state update logic in a try-catch block to handle potential data parsing errors gracefully.

Additionally, I've optimized the logic to find and update the app in the local list by using indexWhere instead of where followed by indexOf, which is more efficient as it avoids a second iteration over the list.

Suggested change
if (appData != null) {
var freshApp = App.fromJson(appData);
var oldApp = apps.where((element) => element.id == id).firstOrNull;
if (oldApp == null) {
return null;
if (oldApp != null) {
var idx = apps.indexOf(oldApp);
apps[idx] = freshApp;
notifyListeners();
}
var idx = apps.indexOf(oldApp);
apps[idx] = App.fromJson(app);
notifyListeners();
return apps[idx];
return freshApp;
}
if (appData != null) {
try {
var freshApp = App.fromJson(appData);
final idx = apps.indexWhere((element) => element.id == id);
if (idx != -1) {
apps[idx] = freshApp;
notifyListeners();
}
return freshApp;
} catch (e) {
Logger.debug('Failed to parse app details for id: $id, error: $e');
return null;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant