Flutter:如何解决渲染库捕获的异常

时间:2020-07-24 12:50:05

标签: flutter listview carousel

这是我遇到的错误

════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderViewport#a644c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
The relevant error-causing widget was
    Carousel 
lib\Screen\test.dart:63
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderViewport#a644c NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
The relevant error-causing widget was
    Carousel 
lib\Screen\test.dart:63
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderIgnorePointer#a9a36 relayoutBoundary=up14 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'

这是我的代码

body:     ListView(

   // scrollDirection: Axis.vertical,
    children: <Widget>[
      Padding(
        padding: EdgeInsets.only(
            left: SizeConfig.safeBlockHorizontal * 5,
            top: SizeConfig.safeBlockHorizontal * 5,
            right: SizeConfig.safeBlockHorizontal * 5),
        child: Material(
          borderRadius: BorderRadius.circular(24.0),
          child: SizedBox(
            width: SizeConfig.safeBlockHorizontal * 80,
            height: SizeConfig.safeBlockHorizontal * 100,
            
            child: StreamBuilder<QuerySnapshot>(
            stream: Firestore.instance.collection('About').snapshots(),
            builder: (context, snapshot) {
              if (snapshot.hasData) {
                return ListView.builder(
                  shrinkWrap: true,
                    itemCount: snapshot.data.documents.length,
                    itemBuilder: (BuildContext context, int index) {
                      _listOfImages = [];
                      for (int i = 0;
                          i < snapshot.data.documents[index].data['image'].length;
                          i++
                          )
                           {
                        _listOfImages.add(NetworkImage(snapshot
                            .data.documents[index].data['image'][i]));
                      }
            return Carousel(
             // boxFit: BoxFit.contain,
              dotBgColor: Colors.transparent,
              dotIncreasedColor: Colors.grey,
              dotSize: 6.0,
              images:  _listOfImages,

);

0 个答案:

没有答案