【发布时间】:2020-12-02 13:09:23
【问题描述】:
我有三个在代码中写的浮动操作按钮。
不知何故,按钮对齐方式与 iPhone 有/没有凹口的行为不同。
我想将按钮与Search this area 按钮对齐。
在 Android 手机上测试它正确对齐。
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Align(
alignment: Alignment.topCenter,
child: Padding(
padding: EdgeInsets.fromLTRB(0, MediaQuery.of(context).padding.top + 100, 0, 0),
child: RaisedButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18.0)),
child: Text('Search this area'),
onPressed: () {}),
),
),
floatingActionButton: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.fromLTRB(0, MediaQuery.of(context).padding.top + 120, 0, 0),
child: Column(
children: [
Container(
width: 40.0,
height: 40.0,
child: FloatingActionButton(
child: Icon(Icons.my_location),
onPressed: () {},
heroTag: null,
backgroundColor: Colors.red,
),
),
Container(
margin: EdgeInsets.fromLTRB(0, 10, 0, 0),
width: 40.0,
height: 40.0,
child: FloatingActionButton(
child: Icon(Icons.map),
onPressed: () {},
heroTag: null,
backgroundColor: Colors.green,
),
),
],
),
),
FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
heroTag: null,
),
],
),
);
}
}
截图
没有缺口 带缺口【问题讨论】: