8000 NoSuchMethodError: The setter 'value=' was called on null. · Issue #22 · peng8350/flutter_pulltorefresh · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

NoSuchMethodError: The setter 'value=' was called on null. #22

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

Closed
stefanJi opened this issue Oct 30, 2018 · 1 comment
Closed

NoSuchMethodError: The setter 'value=' was called on null. #22

stefanJi opened this iss 8000 ue Oct 30, 2018 · 1 comment

Comments

@stefanJi
Copy link

When I firstly call refreshController.sendBack in initState firstly, will throw NoSuchMethodError: The setter 'value=' was called on null.

As follows code:

abstract class BaseListState extends State<BaseListWidget>
    with AutomaticKeepAliveClientMixin<BaseListWidget> {
   RefreshController _refreshController = RefreshController();
   List data;

  @override
  void initState() {
    super.initState();
    _loadNew();
  }

  _loadNew() async {
    final remoteDate = await _loadData();
    if (mounted) {
      setState(() {
        data = remoteDate;
      });
      _refreshController.sendBack(true, RefreshStatus.completed);
      if (page == total) {
        _refreshController.sendBack(false, RefreshStatus.noMore);
      } else {
        _refreshController.sendBack(false, RefreshStatus.canRefresh);
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    return data == null
        ? Center(child: CircularProgressIndicator())
        : SmartRefresher(
            controller: _refreshController,
            enablePullDown: true,
            enablePullUp: true,
            onRefresh: (up) {
              if (up) {
                _loadNew();
              } else {
                _loadMore();
              }
            },
            child: ListView.builder(
                itemCount: data == null ? 0 : data.length,
                itemBuilder: (context, index) {
                  return childBuild(context, index);
                }));
  }
}
@stefanJi
Copy link
Author
stefanJi commented Nov 8, 2018

I have work around this issue. As following :

return SmartRefresher(
        controller: _refreshController,
        onRefresh: (up) {
          if (up) {
            if (!_hasLoadOnce) {
              _hasLoadOnce = true;
            }
            _loadNew();
          } else {
            _loadMore();
          }
        }
);

_loadNew( ) {
    if (_hasLoadOnce) {
        _refreshController.sendBack(true, RefreshStatus.completed);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0