pojoba01
pojoba01

Reputation: 31

Flutter bottom Overflow

Can anyone help me with this exception that I keep running into? I am not sure what attempt next in order to fix the overflow as the panel expands. I've tried wrapping it into a flexible widget but that doesn't seem to fix the issue.

Here is my exception:

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during layout:
A RenderFlex overflowed by 68 pixels on the bottom.

The relevant error-causing widget was: 
  Column file:///Users/selorm/AndroidStudioProjects/flutter_master/lib/src/widgets/weather_widget.dart:17:14
The overflowing RenderFlex has an orientation of Axis.vertical.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.

Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.

The specific RenderFlex in question is: RenderFlex#8829e relayoutBoundary=up1 OVERFLOWING
...  needs compositing
...  parentData: offset=Offset(0.0, 0.0) (can use size)
...  constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=410.6)
...  size: Size(411.4, 410.6)
...  direction: vertical
...  mainAxisAlignment: center
...  mainAxisSize: max
...  crossAxisAlignment: center
...  verticalDirection: down
◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
════════════════════════════════════════════════════════════════════════════════════════════════════

Here is my code:

  @override
   Widget build(BuildContext context) {
    return Center(
      child: Column(
    mainAxisAlignment: MainAxisAlignment.center,
    children: <Widget>[
      Flexible(
        //flex: 2,
        //fit: FlexFit.loose,
      child: Text(
        this.weather.cityName.toUpperCase(),
        style: TextStyle(
            fontWeight: FontWeight.w900,
            letterSpacing: 5,
            color: AppStateContainer.of(context).theme.accentColor,
            fontSize: 25),
      ),
      ),
      SizedBox(
        height: 20,
      ),
      Flexible(
        //flex: 1,
      child:Text(
        this.weather.description.toUpperCase(),
        style: TextStyle(
            fontWeight: FontWeight.w100,
            letterSpacing: 5,
            fontSize: 20,
            color: AppStateContainer.of(context).theme.accentColor),
        ),
      ),
      WeatherSwipePager(weather: weather),
      Padding(
        child: Divider(
          color:
              AppStateContainer.of(context).theme.accentColor.withAlpha(50),
        ),
        padding: EdgeInsets.all(10),
      ),
      ForecastHorizontal(weathers: weather.forecast),
      Padding(
        child: Divider(
          color:
              AppStateContainer.of(context).theme.accentColor.withAlpha(50),
        ),
        padding: EdgeInsets.all(10),
      ),

      Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
        ValueTile("wind speed", '${this.weather.windSpeed} m/s'),
        Padding(
          padding: const EdgeInsets.only(left: 15, right: 15),
          child: Center(
              child: Container(
            width: 1,
            height: 30,
            color: AppStateContainer.of(context)
                .theme
                .accentColor
                .withAlpha(50),
          )),
        ),
        ValueTile(
            "sunrise",
            DateFormat('h:m a').format(DateTime.fromMillisecondsSinceEpoch(
                this.weather.sunrise * 1000))),
        Padding(
          padding: const EdgeInsets.only(left: 15, right: 15),
          child: Center(
              child: Container(
            width: 1,
            height: 30,
            color: AppStateContainer.of(context)
                .theme
                .accentColor
                .withAlpha(50),
          )),
        ),
        ValueTile(
            "sunset",
            DateFormat('h:m a').format(DateTime.fromMillisecondsSinceEpoch(
                this.weather.sunset * 1000))),
        Padding(
          padding: const EdgeInsets.only(left: 15, right: 15),
          child: Center(
              child: Container(
            width: 1,
            height: 30,
            color: AppStateContainer.of(context)
                .theme
                .accentColor
                .withAlpha(50),
          )),
        ),
        ValueTile("humidity", '${this.weather.humidity}%'),
        ]
      ),
    ],
  ),
);

} }

Upvotes: 3

Views: 7371

Answers (1)

Mohamed Sayed
Mohamed Sayed

Reputation: 851

You have to two quick options:

  1. use ListView() with shrinkWrap set to true
     @override
     Widget build(BuildContext context) {
       return ListView(
         shrinkWrap: true,
         children: <Widget>[
           // Children
         ],
       );
     }
  1. wrap Column() with singleChildScrollView()
     @override
     Widget build(BuildContext context) {
       return SingleChildScrollView(
         child: Column(
           mainAxisSize: MainAxisSize.max,
           children: <Widget>[
             // Children
           ],
         ),
       );
     }

That's it

Upvotes: 16

Related Questions