如何在颤动中的不同屏幕分辨率之间具有相同大小的圆圈比例
how to have same size ratio of circle between different screen resolution in flutter
我尝试制作自定义地理围栏,为此,我显示了一个 Url 的 googlemap 并添加了一个带有圆圈的堆栈,我用一个系数调整了大小以获得良好的表示。问题我的系数在任何屏幕设备上都不是动态的
Container ( padding: const EdgeInsets.only(top :160.0),
child : new Card(
elevation: 2.0,
child: new Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
new Container(
child: new Image.network(statichomeMapUri.toString()),
),
FractionalTranslation(
translation: Offset(0.0, 0.0),
child: new Container(
alignment: new FractionalOffset(0.0, 0.0),
decoration: new BoxDecoration(
border: new Border.all(
color: Colors.orangeAccent.withOpacity(0.5),
width: perimetre/3.4, // need to be dynamic
),
shape: BoxShape.circle,
),
),
),
new Container(
//padding: const EdgeInsets.only(bottom:10.0),
margin: new EdgeInsets.all(140.0),
child : Icon(Icons.home, color: Colors.white, size: 25.0),
),
],
),
),
)
使用获取手机屏幕的宽度
MediaQuery.of(上下文)。size.width
并设置任何你想设置的比例
我尝试制作自定义地理围栏,为此,我显示了一个 Url 的 googlemap 并添加了一个带有圆圈的堆栈,我用一个系数调整了大小以获得良好的表示。问题我的系数在任何屏幕设备上都不是动态的
Container ( padding: const EdgeInsets.only(top :160.0),
child : new Card(
elevation: 2.0,
child: new Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
new Container(
child: new Image.network(statichomeMapUri.toString()),
),
FractionalTranslation(
translation: Offset(0.0, 0.0),
child: new Container(
alignment: new FractionalOffset(0.0, 0.0),
decoration: new BoxDecoration(
border: new Border.all(
color: Colors.orangeAccent.withOpacity(0.5),
width: perimetre/3.4, // need to be dynamic
),
shape: BoxShape.circle,
),
),
),
new Container(
//padding: const EdgeInsets.only(bottom:10.0),
margin: new EdgeInsets.all(140.0),
child : Icon(Icons.home, color: Colors.white, size: 25.0),
),
],
),
),
)
使用获取手机屏幕的宽度 MediaQuery.of(上下文)。size.width 并设置任何你想设置的比例