Skip to content
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

many widget errors #9

Closed
heshesh2010 opened this issue Oct 20, 2020 · 2 comments
Closed

many widget errors #9

heshesh2010 opened this issue Oct 20, 2020 · 2 comments

Comments

@heshesh2010
Copy link

heshesh2010 commented Oct 20, 2020

Hi,

when i use PagedListView in body of Scaffold widget it works fine , but when i used it as an element in cloumn or parnet listview i get many errors like :

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
BoxConstraints forces an infinite height.
The relevant error-causing widget was:
PagedListView<int, Food> file:///Users/hesham/StudioProjects/foodlobby_client/lib/src/pages/menu_list.dart:115:9
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
Null check operator used on a null value
The relevant error-causing widget was:
PagedListView<int, Food> file:///Users/hesham/StudioProjects/foodlobby_client/lib/src/pages/menu_list.dart:115:9
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
Null check operator used on a null value
The relevant error-causing widget was:
PagedListView<int, Food> file:///Users/hesham/StudioProjects/foodlobby_client/lib/src/pages/menu_list.dart:115:9
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
Null check operator used on a null value
The relevant error-causing widget was:
PagedListView<int, Food> file:///Users/hesham/StudioProjects/foodlobby_client/lib/src/pages/menu_list.dart:115:9
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderBox was not laid out: RenderShrinkWrappingViewport#f8e22 relayoutBoundary=up18 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1785 pos 12: 'hasSize'
The relevant error-causing widget was:
PagedListView<int, Food> file:///Users/hesham/StudioProjects/foodlobby_client/lib/src/pages/menu_list.dart:115:9

=====

my code :

 @override
  Widget build(BuildContext context) {
return Scaffold(
  key: _con.scaffoldKey,
  drawer: DrawerWidget(),
  appBar: AppBar(
    backgroundColor: Colors.transparent,
    elevation: 0,
    centerTitle: true,
    title: Text(
      _con.foods.isNotEmpty && _con.foods[0].restaurantName != null
          ? _con.foods[0].restaurantName
          : '',
      overflow: TextOverflow.fade,
      softWrap: false,
      style: Theme.of(context)
          .textTheme
          .title
          .merge(TextStyle(letterSpacing: 0)),
    ),
    actions: <Widget>[
      ShoppingCartButtonWidget(
          iconColor: Theme.of(context).hintColor,
          labelColor: Theme.of(context).accentColor)
    ],
  ),
  floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
  body: ListView(
    shrinkWrap: true,
    padding: EdgeInsets.symmetric(vertical: 10),
      children: <Widget>[
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 20),
          child: SearchBarWidget(),
        ),
        ListTile(
          dense: true,
          contentPadding:
              EdgeInsets.symmetric(horizontal: 20, vertical: 10),
          leading: Icon(
            Icons.trending_up,
            color: Theme.of(context).hintColor,
          ),
          title: Text(
            S.of(context).trending_this_week,
            style: Theme.of(context).textTheme.display1,
          ),
          subtitle: Text(
            S.of(context).double_click_on_the_food_to_add_it_to_the,
            style: Theme.of(context)
                .textTheme
                .caption
                .merge(TextStyle(fontSize: 11)),
          ),
        ),
        FoodsCarouselWidget(
            heroTag: 'menu_trending_food', restaurantController: _con),
        ListTile(
          dense: true,
          contentPadding:
              EdgeInsets.symmetric(horizontal: 20, vertical: 10),
          leading: Icon(
            Icons.list,
            color: Theme.of(context).hintColor,
          ),
          title: Text(
            S.of(context).all_menu,
            style: Theme.of(context).textTheme.display1,
          ),
          subtitle: Text(
            S.of(context).longpress_on_the_food_to_add_suplements,
            style: Theme.of(context)
                .textTheme
                .caption
                .merge(TextStyle(fontSize: 11)),
          ),
        ),
    
    PagedListView<int, Food>.separated(
          scrollDirection: Axis.vertical,
      primary: false,
      shrinkWrap: true,
      pagingController: _con.pagingFoodsController,
          builderDelegate: PagedChildBuilderDelegate<Food>(
            itemBuilder: (context, item, index) {
              return FoodItemWidget(
                  heroTag: "menu_list",
                  food: item);
            },
            noMoreItemsIndicatorBuilder: (_) =>
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: ClipRRect(
                    borderRadius: BorderRadius.circular(80),
                    child: RaisedButton(
                      disabledColor: Colors.white,
                      onPressed: null,
                      child: Text("لا يوجد وجبات اخرى"),
                    ),
                  ),
                ),
          ),

          separatorBuilder: (context, index) =>   SizedBox(height: 10),
        )
      ],
    ));

}

@EdsonBueno
Copy link
Owner

EdsonBueno commented Oct 21, 2020

Hi, @heshesh2010 . Today's release (2.2.1) fixes this. Just upgrade the package version and it should work right out of the box.
Although I should mention that using shrinkWrap isn't the ideal way of achieving that sort of layout with widgets preceding your list (even if it was a regular ListView). For a better approach to this, please refer to this section of the cookbook.

Thank you for using the package and opening the issue!

@heshesh2010
Copy link
Author

hi , the problem is solved , but in same widiget i get error :
There are multiple heroes that share the same tag within a subtree.

i make sure there is no hero , when i remove PagedListView the layout works fine when hit any button

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

2 participants