布局流生成器NEEDS-LAYOUT NEEDS-PAINT

时间:2019-04-18 20:17:15

标签: flutter

我正在创建一个流构建器,列出要拉出的用户列表。我正在使用ListView.builder()Cards放在其中。但是,我遇到了很多错误,尤其是与NEEDS-LAYOUT NEEDS-PAINT

这是代码:

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:mobile_hiking_app/Constants.dart';
import 'Database.dart';
import 'HikerPage.dart';

class Hikers extends StatefulWidget {
  @override
  _Hikers createState() => new _Hikers();
}

Database temp = new Database();
Card profileCard(String name, var miles, String profPic) {
  if (name != globalUserName) {
  if (miles == null) {
    miles = 0;
  }
  if (profPic == "") {
    profPic =
        "https://amp.businessinsider.com/images/5899ffcf6e09a897008b5c04-750-750.jpg";
  }
  return new Card(

      child: new Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
    ListTile(
      leading: CircleAvatar(backgroundImage: NetworkImage(profPic)),
      title: Text(name),
      subtitle: new Text("Miles Hiked: " + miles.toString()),
    ),
  ]));
}
else {return null;}
}

class _Hikers extends State<Hikers> {
  @override
  void initState() {
    super.initState();
  }

  Widget build(BuildContext context) {
    Color lightDark = Color(0xff243447);
    return new Scaffold(
        appBar: new AppBar(
          backgroundColor: lightDark,
          title: new Text("Hikers"),
          actions: <Widget>[],
        ),
        body: new Column(children: <Widget>[
          new Flexible(
              child: StreamBuilder(
                  stream: Firestore.instance.collection("USERS").snapshots(),
                  builder: (context, snapshot) {
                    if (!snapshot.hasData) {
                      return Container(child: Center(child: Text("No data")));
                    }
                    return ListView.builder(
                        padding: EdgeInsets.all(8.0),
                        reverse: false,
                        itemCount: snapshot.data.documents.length-1,
                        itemBuilder: (BuildContext context, int index) {
                          String user = snapshot.data.documents[index]["Name"];
                          var miles =
                              snapshot.data.documents[index]["MilesHiked"];
                          String profPic =
                              snapshot.data.documents[index]["profilePic"];
                          return new GestureDetector(
                            onTap: () {
                              Navigator.push(
                                context,
                                MaterialPageRoute(
                                    builder: (context) => HikerPage(
                                          name: user,
                                          profPic: profPic,
                                          miles: miles.toString(),
                                        )),
                              );
                            },
                            child: profileCard(user, miles, profPic),
                          );
                        });
                  })),
        ]));
  }
}

这是错误:

flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown during performLayout():
flutter: RenderPointerListener object was given an infinite size during layout.
flutter: This probably means that it is a render object that tries to be as big as possible, but it was put
flutter: inside another render object that allows its children to pick their own size.
flutter: The nearest ancestor providing an unbounded height constraint is:
flutter:   RenderIndexedSemantics#fec43 relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT
flutter:   creator: IndexedSemantics ← NotificationListener<KeepAliveNotification> ← KeepAlive ←
flutter:   AutomaticKeepAlive ← SliverList ← SliverPadding ← Viewport ← IgnorePointer-[GlobalKey#35708] ←
flutter:   Semantics ← Listener ← _GestureSemantics ←
flutter:   RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#2dfed] ← ⋯
flutter:   parentData: index=0; layoutOffset=0.0 (can use size)
flutter:   constraints: BoxConstraints(w=398.0, 0.0<=h<=Infinity)
flutter:   semantic boundary
flutter:   size: Size(398.0, Infinity)
flutter:   index: 0
flutter: The constraints that applied to the RenderPointerListener were:
flutter:   BoxConstraints(w=398.0, 0.0<=h<=Infinity)
flutter: The exact size it was given was:
flutter:   Size(398.0, Infinity)
flutter: See https://flutter.dev/layout/ for more information.
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0      RenderBox.debugAssertDoesMeetConstraints.<anonymous closure> 
package:flutter/…/rendering/box.dart:1749
flutter: #1      RenderBox.debugAssertDoesMeetConstraints 
package:flutter/…/rendering/box.dart:1823
flutter: #2      RenderBox.size=.<anonymous closure> 
package:flutter/…/rendering/box.dart:1543
flutter: #3      RenderBox.size= 
package:flutter/…/rendering/box.dart:1543
flutter: #4      RenderPointerListener.performResize 
package:flutter/…/rendering/proxy_box.dart:2613
flutter: #5      _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:108
flutter: #6      RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #7      _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #8      RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #9      _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #10     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #11     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #12     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #13     RenderSliverList.performLayout 
package:flutter/…/rendering/sliver_list.dart:165
flutter: #14     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #15     RenderSliverPadding.performLayout 
package:flutter/…/rendering/sliver_padding.dart:182
flutter: #16     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #17     RenderViewportBase.layoutChildSequence 
package:flutter/…/rendering/viewport.dart:407
flutter: #18     RenderViewport._attemptLayout 
package:flutter/…/rendering/viewport.dart:1322
flutter: #19     RenderViewport.performLayout 
package:flutter/…/rendering/viewport.dart:1240
flutter: #20     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #21     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #22     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #23     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #24     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #25     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #26     RenderObject.layout 
flutter: #27     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #28     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #29     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #30     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #31     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #32     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #33     RenderFlex.performLayout 
package:flutter/…/rendering/flex.dart:799
flutter: #34     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #35     MultiChildLayoutDelegate.layoutChild 
package:flutter/…/rendering/custom_layout.dart:142
flutter: #36     _ScaffoldLayout.performLayout 
package:flutter/…/material/scaffold.dart:431
flutter: #37     MultiChildLayoutDelegate._callPerformLayout 
package:flutter/…/rendering/custom_layout.dart:212
flutter: #38     RenderCustomMultiChildLayoutBox.performLayout 
package:flutter/…/rendering/custom_layout.dart:356
flutter: #39     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #40     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #41     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #42     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #43     _RenderCustomClip.performLayout 
package:flutter/…/rendering/proxy_box.dart:1206
flutter: #44     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #45     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #46     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #47     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #48     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #49     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #50     RenderObject.layout 
flutter: #51     RenderStack.performLayout 
package:flutter/…/rendering/stack.dart:510
flutter: #52     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #53     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #54     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #55     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #56     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #57     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #58     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #59     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #60     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #61     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #62     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #63     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #64     RenderOffstage.performLayout 
package:flutter/…/rendering/proxy_box.dart:3015
flutter: #65     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #66     RenderStack.performLayout 
package:flutter/…/rendering/stack.dart:510
flutter: #67     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #68     __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #69     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #70     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #71     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #72     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #73     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #74     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #75     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #76     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #77     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #78     RenderView.performLayout 
package:flutter/…/rendering/view.dart:151
flutter: #79     RenderObject._layoutWithoutResize 
package:flutter/…/rendering/object.dart:1519
flutter: #80     PipelineOwner.flushLayout 
package:flutter/…/rendering/object.dart:766
flutter: #81     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame 
package:flutter/…/rendering/binding.dart:347
flutter: #82     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame 
package:flutter/…/widgets/binding.dart:701
flutter: #83     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback 
package:flutter/…/rendering/binding.dart:286
flutter: #84     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback 
package:flutter/…/scheduler/binding.dart:1012
flutter: #85     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame 
package:flutter/…/scheduler/binding.dart:952
flutter: #86     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> 
package:flutter/…/scheduler/binding.dart:773
flutter: #88     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
flutter: #89     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
flutter: #90     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12)
flutter: (elided one frame from package dart:async-patch)
flutter:
flutter: The following RenderObject was being processed when the exception was fired:
flutter:   RenderPointerListener#9a81c relayoutBoundary=up6 NEEDS-LAYOUT NEEDS-PAINT
flutter:   creator: Listener ← _GestureSemantics ← RawGestureDetector ← GestureDetector ←
flutter:   RepaintBoundary-[<0>] ← IndexedSemantics ← NotificationListener<KeepAliveNotification> ← KeepAlive
flutter:   ← AutomaticKeepAlive ← SliverList ← SliverPadding ← Viewport ← ⋯
flutter:   parentData: <none> (can use size)
flutter:   constraints: BoxConstraints(w=398.0, 0.0<=h<=Infinity)
flutter:   size: Size(398.0, Infinity)
flutter:   behavior: translucent
flutter:   listeners: down
flutter: This RenderObject has no descendants.
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: RenderSemanticsGestureHandler object was given an infinite size during layout.
flutter: Another exception was thrown: RenderRepaintBoundary object was given an infinite size during layout.
flutter: Another exception was thrown: RenderIndexedSemantics object was given an infinite size during layout.
Reloaded 8 of 580 libraries in 813ms.
flutter: Another exception was thrown: RenderIndexedSemantics object was given an infinite size during layout.
flutter: Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 470 pos 12: 'child.hasSize': is not true.

0 个答案:

没有答案