【问题标题】:how to have same size ratio of circle between different screen resolution in flutter如何在颤动中在不同的屏幕分辨率之间具有相同的圆的大小比
【发布时间】:2018-08-26 06:47:27
【问题描述】:

我尝试制作自定义地理围栏,为此,我显示了一个 googlemap 的 Url,并添加了一个带圆圈的堆栈,我使用系数调整了大小以获得良好的表示。问题我的系数在任何屏幕设备上都不是动态的

                             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),
                                      ),
                                    ],
                                  ),
                                ),
                              )

【问题讨论】:

  • 周长的值是多少

标签: size flutter resolution


【解决方案1】:

使用获取手机屏幕的宽度 MediaQuery.of(context).size.width 并设置您想要设置的任何比例

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-19
    • 1970-01-01
    • 2017-03-24
    相关资源
    最近更新 更多