在缩放时避免缩放光标和指针,同时缩放“ TextField”

时间:2020-11-11 11:14:12

标签: flutter scale

我正在使用TextField缩放Transform.scale()TextField会按预期缩放,但光标和编辑选项视图也会被裁剪。

void _incrementCounter() {
    setState(() {
      _scaleFactor = _scaleFactor + 0.3;
    });
  }

  void _deccrementCounter() {
    setState(() {
      _scaleFactor = _scaleFactor - 0.3;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Transform.scale(
            scale: _scaleFactor,
            child: Center(
              child:
                  Container(color: Colors.red, width: 400, child: TextField()),
            )),
      ),
      floatingActionButton: Row(children: <Widget>[
        FloatingActionButton(
          onPressed: _incrementCounter,
          tooltip: 'Increment',
          child: Icon(Icons.zoom_in),
        ),
        FloatingActionButton(
          onPressed: _deccrementCounter,
          tooltip: 'decrement',
          child: Icon(Icons.zoom_out),
        ),
      ]),
    );
  }

正常比例

enter image description here

2.0规模

enter image description here

如何克服光标指针和编辑选项的缩放比例?

0 个答案:

没有答案