如何删除屏幕底部和底部栏之间的底部 space?
how to remove bottom space between bottom of the screen and bottom bar?
如何去除底栏和屏幕底部之间的白色 space。我也尝试在底部容器中应用填充或边距,但它不起作用。请帮我解决这个问题。
嘿,帮帮我,我害怕这个错误。这需要我大部分时间,但我无法解决。请帮助我。
这是我的代码
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:provider/provider.dart';
import 'package:grk_001/Provider/products.dart';
class ProductDetails extends StatelessWidget {
static const String routename = 'ProductDetails';
@override
Widget build(BuildContext context) {
final devicesize = MediaQuery.of(context).size;
final Productid = ModalRoute.of(context).settings.arguments as String;
final loadedproduct = Provider.of<Products>(
context,
).findByid(Productid);
return SafeArea(
maintainBottomViewPadding: true,
child: Scaffold(
appBar: AppBar(
title: Text(loadedproduct.title == null ? '' : loadedproduct.title),
),
body: Container(
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
width: double.infinity,
height: 300,
child: Image.network(
loadedproduct.imageUrl,
fit: BoxFit.cover,
),
),
SizedBox(
height: 15.0,
),
Text(
'₹${loadedproduct.price}',
style: TextStyle(fontSize: 30.0),
),
SizedBox(
height: 10.0,
),
Text(
loadedproduct.description,
softWrap: true,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20.0),
),
Row(
children: <Widget>[
Expanded(
child: FlatButton.icon(
onPressed: () {},
icon: Icon(
Icons.arrow_drop_down,
color: Colors.pink,
),
label: Text(
'Quantity',
style: TextStyle(color: Colors.pink),
)),
),
Expanded(
child: FlatButton.icon(
onPressed: () {},
icon: Icon(
Icons.arrow_drop_down,
color: Colors.pink,
),
label: Text(
'Color',
style: TextStyle(color: Colors.pink),
),
),
)
],
)
],
),
),
Container(
padding: EdgeInsets.zero,
margin: EdgeInsets.zero,
width: double.infinity,
decoration: BoxDecoration(),
child: Row(
children: <Widget>[
Expanded(
flex: 5,
child: FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
),
color: Colors.pink,
onPressed: () {},
child: Text('BUY NOW'),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: Container(
child: Icon(
Icons.favorite,
size: 37.0,
color: Colors.red,
),
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: Container(
child: Icon(
Icons.shopping_cart,
size: 37.0,
color: Colors.red,
),
),
),
),
],
),
)
],
),
),
),
);
}
}
终于找到你的问题了。
问题出在您的 'BUY NOW' 按钮上!它占据额外的高度,因此从底部可以看到它很高。
由于您的图标大小为 37,因此最好使用大于 37 的高度。
为父 Container
和 Button 的 Container
设置它。
另外,记下 Row
的 crossAxisAlignment
。
对你的 'BUY NOW' 按钮做这样的事情,
Container(
width: MediaQuery.of(context).size.width,
height: 40.0,
color: Colors.green,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Expanded(
flex: 5,
child: Container(
height: 40.0,
child: FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
),
color: Colors.pink,
onPressed: () {},
child: Text('BUY NOW'),
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: Container(
child: Icon(
Icons.favorite,
size: 37.0,
color: Colors.red,
),
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: Container(
child: Icon(
Icons.shopping_cart,
size: 37.0,
color: Colors.red,
),
),
),
),
],
),
)
希望这能解决您的问题。
这是我的代码
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:provider/provider.dart';
import 'package:grk_001/Provider/products.dart';
class ProductDetails extends StatelessWidget {
static const String routename = 'ProductDetails';
@override
Widget build(BuildContext context) {
final devicesize = MediaQuery.of(context).size;
final Productid = ModalRoute.of(context).settings.arguments as String;
final loadedproduct = Provider.of<Products>(
context,
).findByid(Productid);
return SafeArea(
maintainBottomViewPadding: true,
child: Scaffold(
appBar: AppBar(
title: Text(loadedproduct.title == null ? '' : loadedproduct.title),
),
body: Container(
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
width: double.infinity,
height: 300,
child: Image.network(
loadedproduct.imageUrl,
fit: BoxFit.cover,
),
),
SizedBox(
height: 15.0,
),
Text(
'₹${loadedproduct.price}',
style: TextStyle(fontSize: 30.0),
),
SizedBox(
height: 10.0,
),
Text(
loadedproduct.description,
softWrap: true,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20.0),
),
Row(
children: <Widget>[
Expanded(
child: FlatButton.icon(
onPressed: () {},
icon: Icon(
Icons.arrow_drop_down,
color: Colors.pink,
),
label: Text(
'Quantity',
style: TextStyle(color: Colors.pink),
)),
),
Expanded(
child: FlatButton.icon(
onPressed: () {},
icon: Icon(
Icons.arrow_drop_down,
color: Colors.pink,
),
label: Text(
'Color',
style: TextStyle(color: Colors.pink),
),
),
)
],
)
],
),
),
Container(
padding: EdgeInsets.zero,
margin: EdgeInsets.zero,
width: double.infinity,
decoration: BoxDecoration(),
child: Row(
children: <Widget>[
Expanded(
flex: 5,
child: FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
),
color: Colors.pink,
onPressed: () {},
child: Text('BUY NOW'),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: Container(
child: Icon(
Icons.favorite,
size: 37.0,
color: Colors.red,
),
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: Container(
child: Icon(
Icons.shopping_cart,
size: 37.0,
color: Colors.red,
),
),
),
),
],
),
)
],
),
),
),
);
}
}
终于找到你的问题了。
问题出在您的 'BUY NOW' 按钮上!它占据额外的高度,因此从底部可以看到它很高。
由于您的图标大小为 37,因此最好使用大于 37 的高度。
为父 Container
和 Button 的 Container
设置它。
另外,记下 Row
的 crossAxisAlignment
。
对你的 'BUY NOW' 按钮做这样的事情,
Container(
width: MediaQuery.of(context).size.width,
height: 40.0,
color: Colors.green,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Expanded(
flex: 5,
child: Container(
height: 40.0,
child: FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
),
color: Colors.pink,
onPressed: () {},
child: Text('BUY NOW'),
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: Container(
child: Icon(
Icons.favorite,
size: 37.0,
color: Colors.red,
),
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: Container(
child: Icon(
Icons.shopping_cart,
size: 37.0,
color: Colors.red,
),
),
),
),
],
),
)
希望这能解决您的问题。