Flutter Web:如何修复SelectableText对齐方式?

时间:2019-12-16 08:48:07

标签: flutter flutter-layout flutter-web

我在Icon中有一个SelectableTextRow,但是SelectableText似乎没有正确对齐。

现在看起来像这样

enter image description here

预期结果:

enter image description here

这是我正在使用的代码,

        Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Icon(FontAwesomeIcons.whatsapp),
            const Padding(padding: EdgeInsets.only(left: 8)),
            SelectableText(
              '+91-8**2**8**5',
              textAlign: TextAlign.center,
              style: Theme.of(context).textTheme.title,
            )
          ],
        ),

PS:它可以与Text一起很好地工作,但我想改为SelectableText

1 个答案:

答案 0 :(得分:1)

问题网络上的可选文本窗口小部件减半  https://github.com/flutter/flutter/issues/40663已解决。
请升级到最新版本
附上我完整的测试代码和结果

enter image description here

完整的测试代码

 function callAjax() {
        $.ajax({
            url: '/device_new',
            type: 'GET',
            dataType: 'json',
            success: function(data) {    
                markerLayer.clearLayers();

                var coordinates = data;
                for (var i = 0; i < coordinates.length; i++) {
                    if (coordinates[i].x && coordinates[i].y) {
                        marker = L.marker([coordinates[i].x, coordinates[i].y])
                            .bindPopup("Device: " + coordinates[i].device_type + '<br>' + "Time: " + coordinates[i].datetime)

                        marker.addTo(markerLayer);
                    }
                }

                map.fitBounds(markerLayer.getBounds());

            },

        });
        setInterval(callAjax, 3000);
    }


function loadMap() {
            // Where you want to render the map.
            var element = document.getElementById('osm-map');

            // Height has to be set. You can do this in CSS too.
            element.style = 'height:405px;', 'width:500px;';

            // Create Leaflet map on map element.
            map = L.map(element);

            // Add OSM tile leayer to the Leaflet map.
            L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
                attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
            }).addTo(map);

            map.pm.addControls({
                position: 'topleft',
            });

//********************** ADD HERE **************    
        var markerLayer = L.featureGroup().addTo(map);  

        }