Why do the widgets enlarge in size when I refresh?
huynguyen96419 opened this issue · comments
Sometimes when I swipe down to refresh the data, the size of the widgets enlarges. But when I scroll down, they return to their normal size.
From this:
My code:
class ListLoader extends StatelessWidget {
final Widget child;
final RefreshController controller;
final Future<dynamic>? Function()? onRefresh;
final Future<dynamic>? Function()? onLoadMore;
final bool hasNext;
final bool hasLoadComplete;
const ListLoader({
Key? key,
required this.child,
required this.controller,
this.hasNext = false,
this.onRefresh,
this.onLoadMore,
this.hasLoadComplete = true,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return RefreshConfiguration(
headerBuilder: () => ClassicHeader(
refreshingText: LocaleKeys.smartRefresh_header_refreshing.tr(),
releaseText: LocaleKeys.smartRefresh_header_releaseToRefresh.tr(),
completeText: LocaleKeys.smartRefresh_header_refreshCompleted.tr(),
idleText: LocaleKeys.smartRefresh_header_pullDownRefresh.tr(),
failedText: LocaleKeys.smartRefresh_header_refreshFailed.tr(),
),
footerBuilder: () => ClassicFooter(
loadingText: LocaleKeys.smartRefresh_footer_loading.tr(),
noDataText: LocaleKeys.smartRefresh_footer_noData.tr(),
canLoadingText: LocaleKeys.smartRefresh_footer_releaseToLoadMore.tr(),
idleText: LocaleKeys.smartRefresh_footer_pullUpToLoadMore.tr(),
failedText: LocaleKeys.smartRefresh_footer_loadMoreFailed.tr(),
),
child: SmartRefresher(
controller: controller,
onLoading: _loadMore,
onRefresh: _refresh,
enablePullUp: hasNext && onLoadMore != null,
enablePullDown: onRefresh != null,
child: child,
),
);
}
Future<void> _loadMore() async {
if (controller.isRefresh) return;
onLoadMore?.call()?.then(
(_) => controller.loadComplete(),
onError: (_) => controller.loadFailed(),
);
}
Future<void> _refresh() async {
if (hasLoadComplete && controller.isLoading) {
controller.loadComplete();
}
onRefresh?.call()?.then(
(_) => controller.refreshCompleted(),
onError: (_) => controller.refreshFailed(),
);
if (SessionManager.instance.user != null) {
getIt<IAuthenticationRepository>().handshake(
firebaseToken: await FirebaseMessaging.instance.getToken() ?? '');
}
}
}
I using it like this:
ListLoader(
controller: _refreshController,
onRefresh: () => _initData(isRefresh: true),
hasNext: false,
hasLoadComplete: false,
child: SingleChildScrollView(
child: Column(
children: [
Widget...])))
Future<dynamic> _initData({bool isRefresh = false}) async {
return Future.wait([
_bloc
.getMenus(),
]);
}
For setting the height and width of widgets, I use ScreenUtil().setHeight or ScreenUtil().setWidth, while for font size, I use ScreenUtil().setSp.
So I don't understand why the size is enlarged like that. Help me, pls.
Facing the same issue.
The same problem occurred when I upgraded the flutter version to the latest 3.19.2, then I downgraded the flutter version to 3.13.9 and the problem disappeared
Facing the same issue.
Facing the same issue.
I solved this problem using a lower version of flutter
Facing the same issue.
Facing the same issue.
I solved this problem using a lower version of flutter
I removed the package and have been using refresh indicator by Flutter, lowering Flutter version bad , but if fine for u then ok.
I fixed this issue with set physic for SmartRefresher:
physics: const BouncingScrollPhysics(),