Can anyone help me resolve this error: A Renderflex overflowed by 473 pixels on the bottom

Asked

Viewed 24 times

0

import 'dart:convert';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:singlecheff/consts/consts.dart';
import 'package:flutter/material.dart';
import 'package:singlecheff/functions/fn_business.dart';
import 'package:singlecheff/functions/fn_utils.dart';

class CategoriasViewPage extends StatefulWidget {
  CategoriasViewPage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _CategoriasViewPage createState() => new _CategoriasViewPage();
}

class _CategoriasViewPage extends State<CategoriasViewPage> {
  String url;

  @override
  void initState() {
    url = prefs.getString('serverHost') + 'listar_grupos';
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: Text("Categorias"),
        backgroundColor: secondColor,
        leading: IconButton(
          icon: const Icon(Icons.arrow_back_ios),
          onPressed: () {
            confirmarVoltarParaControles(context);
          },
        ),
      ),
      body: SizedBox(
        child: FutureBuilder(
          future: fetchData(url).then((response) {
            return jsonDecode(response.body)['Data'];
          }),
          builder: (context, snapshot) {
            if (snapshot.data != null) {
              List<dynamic> result = snapshot.data;
              return SingleChildScrollView(
                child: SizedBox(
                  child: Column(
                    mainAxisSize: MainAxisSize.max,
                    children: [
                      Container(
                        margin: EdgeInsets.only(top: 20, bottom: 20),
                        child: Center(
                          child: Text(
                            controleAtual['descr_controle'],
                            style: TextStyle(fontSize: 20),
                          ),
                        ),
                      ),
                      Container(
                        decoration: BoxDecoration(
                          border: Border(
                            bottom: BorderSide(color: Colors.black12),
                          ),
                        ),
                      ),
                      ListView.builder(
                        scrollDirection: Axis.vertical,
                        shrinkWrap: true,
                        itemCount: result.length,
                        itemBuilder: (context, index) {
                          return Container(
                                margin: defaultMargin20,
                                decoration: BoxDecoration(
                                  border: Border(
                                    bottom: BorderSide(color: Colors.black12),
                                  ),
                                ),
                                child: ListTile(
                                  leading: Icon(Icons.apps),
                                  title: Text(result[index]['gru_descricao']),
                                  onTap: () {
                                    grupoAtual = result[index]['gru_id'];
                                    Navigator.of(context)
                                        .pushNamed("/subcategorias");
                                  },
                                ),
                          );
                        },
                      )
                    ],
                  ),
                ),
              );
            } else {
              return SpinKitDualRing(
                color: secondColor,
                size: 50.0,
              );
            }
          },
        ),
      ),
    );
  }
}

You’re making that mistake:

A Renderflex overflowed by 473 pixels on the bottom.

I’ve tried using the SingleChildScrollView, but it worked only at the top, now at the ListView.builder it didn’t work.

If anyone can help me, I’d appreciate it.

  • I can’t simulate because I don’t have the data, but try to put Listview.Builder() inside an expanded()

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.