简体   繁体   中英

How to fix error: “ The return type 'SliverStaggeredGrid' isn't a 'Widget', as defined by anonymous closure ” in Flutter?

Im trying to set up a SliverStaggeredGrid widget inside of a SliverToBoxAdapter .
I've already imported the package flutter_staggered_grid_view: "^0.2.5" in pubspec.yaml and imported by using

 import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';

but is not working.

The DartAnalysis is returning:

error: The return type 'SliverStaggeredGrid' isn't a 'Widget', as defined by anonymous closure. (return_of_invalid_type_from_closure at [loja_virtual] lib\tabs\home_tab.dart:50)

This is my first question, so my bad if im not introducing well my problem.

I've tried to update the version in pubspec.yaml , tried to use SliverStaggeredGrid.countBuilder but it didn't work.
My Flutter version is the latest.

Pubspec dependencies

See error

1) Flutter Upgrade

2) Restart your IDE

That should solve.

Best Regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM