import 'dart:async'; import 'package:easy_refresh/easy_refresh.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:wallpaperx/common/components/view_state_widget.dart'; class BaseEasyRefresh extends StatelessWidget { const BaseEasyRefresh({ super.key, required this.controller, this.header, this.footer, this.onRefresh, this.onLoad, this.refreshOnStart = false, required this.viewState, required this.child, this.width, this.height, }); final EasyRefreshController controller; final Header? header; final Footer? footer; final FutureOr Function()? onRefresh; final FutureOr Function()? onLoad; final bool refreshOnStart; final ViewState viewState; final Widget child; final double? width; final double? height; @override Widget build(BuildContext context) { return EasyRefresh( controller: controller, header: header ?? const ClassicHeader(), footer: footer ?? const ClassicFooter(), onRefresh: onRefresh, onLoad: onLoad, refreshOnStart: refreshOnStart, child: viewState == ViewState.normal ? child : SingleChildScrollView( child: SizedBox( width: width ?? 1.sw, height: height ?? 300.h, child: ViewStateWidget( viewState: viewState, child: child, ), ), ), ); } }