-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance Enhancements #2089
base: experimental
Are you sure you want to change the base?
Performance Enhancements #2089
Conversation
…e-implementation implemented cached network image
…ariable in wifi card
Implemented Lazy Loading
Kristhian stateless conversion
@parthshindee @klortiz13 Thank you for the great work guys. However, I'm seeing some inconsistencies with the way that functional methods are being used on data. Before we approve this PR, let's all meet to go over this. This is a good case study for the code style guide project. |
if (MediaQuery.of(context).orientation == Orientation.landscape) { | ||
return ScalingUtility.horizontalSafeBlock * 1; | ||
} | ||
return ScalingUtility.horizontalSafeBlock * 3; | ||
} | ||
|
||
double fontSizeForTablet() { | ||
double fontSizeForTablet(BuildContext context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functions that use BuildContext do not need to pass it as a parameter. Use the context instance variable from the class itself.
} | ||
// RegExp multiPager = RegExp(r' \(\d+/\d+\)$'); | ||
// Filter the models and create a list of only the valid ones | ||
List<Widget> locationsList = data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't tell if this is proper usage of functional-style iterator methods. Let's try to rework this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@parthshindee let's meet on this one individually to see the best solution. Possible precedent case for the official Campus Mobile Style Guide
final placeholderPhotoUrl = dotenv.get('PLACEHOLDER_PERSON_PHOTO'); | ||
bool isValidId = false; | ||
class EmployeeIdCard extends StatelessWidget { | ||
final String cardId = "employee_id"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-evaluate if this and others like it can be made into const variables.
@@ -41,7 +30,10 @@ class _EmployeeIdCardState extends State<EmployeeIdCard> { | |||
isLoading: Provider.of<EmployeeIdDataProvider>(context).isLoading, | |||
titleText: CardTitleConstants.titleMap[cardId], | |||
errorText: Provider.of<EmployeeIdDataProvider>(context).error, | |||
child: () => isValidId | |||
child: () => (employeeModel != null && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider putting this into a static private method unless it is only used in this function just once.
@@ -64,6 +64,7 @@ class FinalsCard extends StatelessWidget { | |||
Widget buildFinalsCard(Map<String, List<SectionData>> finalsData, | |||
DateTime? lastUpdated, String? nextDayWithClasses, BuildContext context) { | |||
try { | |||
// Flatten the data into a single list of ListTile widgets | |||
List<Widget> listToReturn = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be converted into functional-style methods.
Summary
This PR addresses performance issues related to lazy loading, stateless widgets, and uncached images (Issue #2068, #2069, #2070).
Changelog
[General] [Change] - Stateful Widget to Stateless where possible
[General] [Add] - Lazy loading to all list like components
[General] [Add] - Caching images
Test Plan
There should be no functional changes in the mobile app. Everything should remain the same. This PR is only intended to improve performance significantly.