flutter)如何让按钮位置根据屏幕大小自动调整?

flutter)How can I make the button position automatically adjust according to the screen size?

我正在用 flutter 制作一个学习应用程序。

在我们的应用程序中,您必须在图片上放置一个按钮。

所以,在图片上使用定位,我做了如下图。

      @override
  Widget build(BuildContext context){
    return Scaffold(
      backgroundColor: Colors.white,
      body: Stack(
        fit: StackFit.expand,
        children: <Widget>[
          Image(
              image: AssetImage("assets/oral_structure.png"),
              fit: BoxFit.fitWidth
          ),
          Positioned(
              top:385, left:17,
              child: FlatButton(
                child: Text('ㅂ', style: TextStyle(fontSize: 30,fontWeight: FontWeight.bold)),
                shape: CircleBorder(),
                onPressed: (){
                  Navigator.push(context, MaterialPageRoute(builder: (context) => B()),);
                },
              )
          ),//ㅂ

但是,问题在于使用大屏幕 phone 时按钮的位置会发生变化。

如何防止这种情况发生?

按钮似乎总是在同一个地方。它应该与屏幕尺寸无关。

我怀疑你的问题出在文本的 fontSize 上。

尝试删除 fontSize:,它应该可以解决您的问题

编辑 1:

问题出在 fit: StackFit.expand,它强制按钮展开。您可以保留它,但将按钮包裹在 SizedBox

const SizedBox(
  width: 200.0,
  height: 100.0,
  child: FlatButton(// your code here...),
)

尝试获取屏幕的宽度和高度,并根据它用收音机计算。