user-interface - 如何调整 TextField 的后缀/suffixIcon 高度?

标签 user-interface flutter textfield flutter-layout

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: SafeArea(
        child: Scaffold(
          body: Column(
            children: [
              Container(
                color: Colors.orange,
                child: TextField(
                  decoration: InputDecoration(
                    suffix: IconButton(
                        icon: Icon(Icons.check_circle),
                        onPressed: () {
                          print('222');
                        }),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

如何强制 check_circle 图标自动调整大小以匹配实际 TextField 的高度,即,根据其光标高度?

最佳答案

改用suffixIcon

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: SafeArea(
        child: Scaffold(
          body: Column(
            children: [
              Container(
                color: Colors.orange,
                child: TextField(
                  decoration: InputDecoration(
                    suffixIcon: IconButton(
                        icon: Icon(Icons.check_circle),
                        onPressed: () {
                          print('222');
                        }),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

关于user-interface - 如何调整 TextField 的后缀/suffixIcon 高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56589170/

相关文章:

java - 如何通过避免重复来缩短 Tic Tac Toe 代码

ios - 如何让 iOS Button 在按下时提供视觉反馈?

flutter - 如何将 CachedNetworkImage 转换为 ImageProvider?

Javafx Textfield - getText() 为空?

java - 在单独的方法/类中声明时,JLabels 和 TextFields 不会出现

html - 我怎样才能使弹出窗口可滚动而没有内容

facebook - Facebook 的 Like 按钮的纯文本版本?

flutter - 如何在 IntelliJ Idea 中嵌套自动生成的 Dart 文件?

flutter 如何使用手势检测器在 onTap 后更改图像

ios - 文本字段未检测到触摸