Bloc: Getting build function returned null issue on first time then it works fine

Created on 2 Jun 2020  路  4Comments  路  Source: felangel/bloc

@override
Widget build(BuildContext context) {
return Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
color: Colors.white,
child: Scaffold(
body: BlocBuilder(
builder: (context, state) {
if (state is RestaurantInitialState) {
_shimmerList();
} else if (state is Loading) {
_shimmerList();
} else if (state is RestaurantMenuFetched) {
return _menuListItem(state.response);
} else if (state is Failed) {
return buildErrorUi(state.message);
} else {
return buildErrorUi(StringResources.somethingWentWrong);
}
}
),
),
);
}

question

Most helpful comment

Ohh! Thanks a lot , i thought it would return from the internal methods widgets :D
Now its working fine 馃憤

All 4 comments

Hi @mahisingh1 馃憢
Thanks for opening an issue!

Can you please describe the problem you're having more clearly and provide a link to a complete application that reproduces the issue? Thanks 馃憤

I am working with Bloc . I have provided bloc builder to widget , now the problem is on the very first time it shows Build function returns null after that is works perfectly.

@mahisingh1 it looks like you're not returning a widget. Please add a return before _shimmerList and let me know if that helps 馃憤

if (state is RestaurantInitialState) {
  return _shimmerList();
} else if (state is Loading) {
  return _shimmerList();
} else if (state is RestaurantMenuFetched) {...}

Ohh! Thanks a lot , i thought it would return from the internal methods widgets :D
Now its working fine 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rsnider19 picture rsnider19  路  3Comments

Reidond picture Reidond  路  3Comments

craiglabenz picture craiglabenz  路  3Comments

abinvp picture abinvp  路  3Comments

hivesey picture hivesey  路  3Comments