简体   繁体   中英

RenderBox was not laid out

This is the error I have:

RenderBox was not laid out: RenderSemanticsGestureHandler#416ac NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1940 pos 12: 'hasSize'
The relevant error-causing widget was: 
  Column file:///C:/Users/srini/AndroidStudioProjects/idealwieght/lib/Input%20Page.dart:21:13

Here is the code:

import 'package:flutter/material.dart';
import 'constants.dart';
import 'Gesture detector.dart';

int height = 180;

class InputPage extends StatefulWidget {
  @override
  _InputPageState createState() => _InputPageState();
}

  

         class _InputPageState extends State<InputPage> {
          int height = 180;
    
          Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('IdealWeightCalculator'),
            backgroundColor: Colors.blue,
          ),
            body: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              Expanded(
                child: ResusableDectector(
                  colour: kContainerColor,
                  cardChild: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text(
                        'HEIGHT',
                        style: KlabelTextStyle,
                      ),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        textBaseline: TextBaseline.alphabetic,
                        children: <Widget>[
                          Text(
                            height.toString(),
                            style: KlabelTextStyle,
                          ),
                          Text(
                            'cm',
                            style: KlabelTextStyle,
                          ),
                           SliderTheme(
                            data: SliderTheme.of(context).copyWith(
                                activeTrackColor: Color(0xFFff377f),
                                inactiveTrackColor: Color(0xFFffffff),
                                thumbColor: Color(0xFFb00203),
                                overlayColor: Color(0xFF4169E1),
                                thumbShape:
                                    RoundSliderThumbShape(enabledThumbRadius: 15.0),
                                overlayShape:
                                    RoundSliderOverlayShape(overlayRadius: 30.0)),
                            child: Slider(
                              value: height.toDouble(),
                              min: 120.0,
                              max: 220.0,
                              onChanged: (double newValue) {
                                setState(() {
                                  height = newValue.round();
                                });
                              },
                            ),
                          ),`
                        ],
                      ),
                    ],
                  ),
                ),
              ),
            ],
          ),
        );
      }
    }

I solved it myself for anyone else with same question just change constant boxconstraints in box.dart file.Change width to 20.0,height to 30.0

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