import 'package:flutter/material.dart';
class AddPlaceScreen extends StatefulWidget {
static const routeName = '/add-place';
@override
_AddPlaceScreenState createState() => _AddPlaceScreenState();
}
class _AddPlaceScreenState extends State<AddPlaceScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Add new Place data'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('User Inputs'),
ElevatedButton.icon(
onPressed: () {},
icon: Icon(Icons.add),
label: Text('Add Place'),
),
],
),
);
}
}
在這里,我在位于頁面底部的升高按鈕下有一個空間,請提供任何解決方案以將其洗掉。
uj5u.com熱心網友回復:

請參考以下代碼
在 ElevatedButton.icon Widget 中添加這段代碼
style: ButtonStyle( tapTargetSize: MaterialTapTargetSize .shrinkWrap, /* 請添加這個以避免填充 */ ),
class AddPlaceScreen extends StatefulWidget {
static const routeName = '/add-place';
@override
_AddPlaceScreenState createState() => _AddPlaceScreenState();
}
class _AddPlaceScreenState extends State<AddPlaceScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Add new Place data'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('User Inputs'),
ElevatedButton.icon(
style: ButtonStyle(
tapTargetSize: MaterialTapTargetSize
.shrinkWrap, /* Please add this to avoid padding */
),
onPressed: () {},
icon: Icon(Icons.add),
label: Text('Add Place'),
),
],
),
);
}
}
uj5u.com熱心網友回復:
試試下面的代碼希望對你有幫助。你也BottomSheet可以
uj5u.com熱心網友回復:
為了實作這一目標,remove the drop shadow并extra margin圍繞ElevatedButton。
對于這個設定elevation to 0,洗掉陰影。
要消除按鈕周圍的額外邊距,請使用材料選項卡目標大小并將其設定為MaterialTabTargetSize.shrinkWrap。MaterialTabTargetSize 基本上確保你有一個更大的空間,你可以用手指點擊,如果我們通過將它設定為 .shrinkWrap 來縮小它,你就可以擺脫額外的邊距。
在 ElevatedButton 中添加以下代碼:
tapTargetSize: MaterialTabTargetSize.shrinkWrap,
elevation: 0,
所以通過在這里設定,按鈕現在真的位于螢屏的末端。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/365643.html
上一篇:如何使用Countif函式計算在Google表格A列或B列中具有特定值的行?
下一篇:無法獲取按鈕背景顏色
