0
I’m trying to make a very simple movie listing app, but when I did a footer, it was on top of the Scaffold widgets, covering some of them, like this:
Follows the code:
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_State createState() => _State();
}
class _State extends State<MyApp> {
bool mudado = false;
final amountGet = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Isso é uma appBar'),
backgroundColor: Colors.orange,
centerTitle: true,
),
body: Padding(
padding: EdgeInsets.all(30),
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
child: TextField(
controller: amountGet,
textAlign: TextAlign.left,
decoration: InputDecoration(
hintText: 'Digite aqui sua busca',
hintStyle: TextStyle(color: Colors.grey),
),
),
),
body(),body(),body(),body(),body(),body(),body(),body(),body(),
],
),
),
),
bottomSheet: Expanded(
flex: 2,
child: Container(
color: Colors.grey[200],
height: 230,
width: 700,
child: Padding(
padding: EdgeInsets.all(30),
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"nome do filme",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.grey[700],
),
),
Text(
"R\$ 55,00",
style: TextStyle(
color: Colors.orange,
fontWeight: FontWeight.bold,
fontSize: 20),
),
],
),
Padding(
padding: EdgeInsets.only(top: 20),
child: Row(
children: [
Text(
"VALOR TOTAL SELECIONADO: R\$ 65,40",
style: TextStyle(
color: Colors.grey[700],
),
),
],
),
),
Padding(
padding: EdgeInsets.only(top: 20),
child: FlatButton(
onPressed: () {
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Text(amountGet.text),
);
},
);
},
color: Colors.indigo[800],
child: Text(
'Comprar',
style: TextStyle(
color: Colors.white,
),
),
),
),
],
),
),
),
),
);
}
body() {
return Column(
children: [
Padding(
padding: EdgeInsets.only(left: 15),
child: Row(
children: [
Checkbox(
focusColor: Colors.grey,
activeColor: Colors.grey[400],
value: true,
onChanged: (value) => value,
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Total:",
textScaleFactor: 1,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.grey[700],
),
),
Padding(
padding: EdgeInsets.fromLTRB(30, 0, 20, 0),
child: Text(
"R\$ 55,00",
style: TextStyle(
color: Colors.grey[700],
fontWeight: FontWeight.bold,
fontSize: 20),
),
),
],
),
],
),
),
Padding(
padding: EdgeInsets.only(left: 30, right: 30),
child: Container(
decoration: BoxDecoration(
border: Border(
left: BorderSide(
width: 2,
color: Colors.grey[400],
),
),
),
child: Padding(
padding: EdgeInsets.fromLTRB(20, 0, 20, 5),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
children: [
Text(
"Duração: 120 minutos",
textScaleFactor: 1.2,
),
],
),
Row(
children: [
Text(
"Data Lançamento: 00/00/0000",
textScaleFactor: 1.2,
),
],
),
Row(
children: [
Text(
"Direção: fulano",
textScaleFactor: 1.2,
),
],
),
],
),
),
),
),
],
);
}
}
Even with Singlechildscrollview(), the footer is still blocking the shortlist.
– Kaya Ryuuna
@Kayaryuuna I’m sorry, I didn’t realize that the checkbox was the first widget of each item... You really need to use the bottomSheet?
– Matheus Ribeiro
I wanted to have a footer on this page, the bottomSheet was one of the options I found, which worked, but it covers the widgets. I even tried to put it next to the column, but it didn’t work.
– Kaya Ryuuna
@Kayaryuuna updated my answer
– Matheus Ribeiro
thank you very much, I did not know this function Mediaquery! It will be of great help in the future! :D
– Kaya Ryuuna