I am making a settings page and the layout is a container with a set height and then under it a listview however this listview needs a set height; so it works when I wrap it in a container and give it a height however it doesn't work if I wrap it in a expanded.

I have tried many things like putting it in a layout builder and giving the height as BoxConstraints.maxHeight and a lot of other tricks which should work but don't.

class Settings extends StatelessWidget {
  Settings({@required this.userInfo, @required this.licenseInfo});
  final userInfo;
  final licenseInfo;
  @override
  Widget build(BuildContext context) {
    double width = MediaQuery.of(context).size.width;
    double height = MediaQuery.of(context).size.height;
    return GestureDetector(
      onTap: () {
        FocusScope.of(context).requestFocus(new FocusNode());
        SystemChannels.textInput.invokeMethod('TextInput.hide');
      },
      child: Scaffold(
          resizeToAvoidBottomPadding: false,
          backgroundColor: Colors.transparent,
          appBar: AppBar(
            elevation: 0.0,
            backgroundColor: Color(0xFF77FDA7),
            title: Text('Settings',
                style: TextStyle(color: darkGrey, fontWeight: FontWeight.w600)),
          ),
          body: Column(
            children: <Widget>[
              Stack(
                children: <Widget>[
                  Container(
                    height: 91,
                    width: width,
                    decoration: BoxDecoration(gradient: greenGradient),
                  ),
                  Column(
                    mainAxisSize: MainAxisSize.max,
                    children: <Widget>[

                      SettingsProfile(
                          userInfo: this.userInfo,
                          licenseInfo: this.licenseInfo),
                      SizedBox(
                        height: 300,
                        child: SettingsList(),
                      ),
                    ],
                  ),
                ],
              ),
            ],
          )),
    );
  }
}

As you see there is a stack and another column however these are just parts of the UI and I need them. They do not have anything to do with me trying to fix this issue. PLEASE HELP as I need this listview to take up all available space in the column without overflowing.

0 Answers