import 'dart:async';

import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter/material.dart';

import 'NullDataView.dart';

class mListView extends StatelessWidget {
  ScrollController controller;
  List<Widget> children;
  EasyRefreshController? easyRefreshController;
  final FutureOr? Function()? onRefresh;
  final FutureOr? Function()? onLoad;

  mListView(
      {super.key, this.easyRefreshController,
      required this.controller,
      this.onRefresh,
      required this.children,
      this.onLoad});

  @override
  Widget build(BuildContext context) {
    var itemChildren=children.isNotEmpty ? children : [const NullDataView()];
    return easyRefreshController != null
        ? EasyRefresh(
            controller: easyRefreshController,
            onRefresh: onRefresh,
            onLoad: onLoad,
            child: ListView(
              controller: controller,
              children: itemChildren,
            ))
        : ListView(
            controller: controller,
            children: itemChildren,
          );
  }
}
