appditto / natrium_wallet_flutter

Natrium - Fast, Robust & Secure NANO Wallet, now written with Flutter.
Other
863 stars 327 forks source link

Use ListView.builder for rendering transactions lists #192

Open DanielOsorio01 opened 10 months ago

DanielOsorio01 commented 10 months ago

Hello. Regarding the following code: https://github.com/appditto/natrium_wallet_flutter/blob/1e046ea64a23d54ec30138361d68ed5993a1efd5/lib/ui/home_page.dart#L547C3-L644C6

For better perfomance, it is recommended to use ListView.builder

DanielOsorio01 commented 10 months ago

This is an example of how to implement it:

// Return widget for list
Widget _getListWidget(BuildContext context) {
  if (StateContainer.of(context).wallet == null ||
      StateContainer.of(context).wallet.historyLoading) {
    // Loading Animation
    return ReactiveRefreshIndicator(
      backgroundColor: StateContainer.of(context).curTheme.backgroundDark,
      onRefresh: _refresh,
      isRefreshing: _isRefreshing,
      child: ListView.builder(
        padding: EdgeInsetsDirectional.fromSTEB(0, 5.0, 0, 15.0),
        itemCount: _getLoadingTransactionCount(), // Define this function
        itemBuilder: (context, index) {
          return _buildLoadingTransactionCard(index, context);
        },
      ),
    );
  } else if (StateContainer.of(context).wallet.history.length == 0) {
    // Code for when wallet history is empty
  } else {
    // Code for when wallet history is not empty
  }
  // Additional code for other cases
}
arshnirmal commented 10 months ago

Hey, i would like to work on this issue, can you assign it to me?