dart 如何删除在Flutter中键盘上方创建的空间

k3fezbri  于 2023-04-27  发布在  Flutter
关注(0)|答案(1)|浏览(111)

如何消除键盘顶部创建白色?我做了所有我能想到的,但我没有得到任何结果

@override
  Widget build(BuildContext context) {
    final screenWidth = ScreenSizeService(context).width;
    final screenHeight = ScreenSizeService(context).height;
    var selected;
    return Scaffold(
      resizeToAvoidBottomInset: false,
      body: Container(
        child: TextField(),
      ),
    );
  }
}
l7wslrjt

l7wslrjt1#

你能试试这个吗

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: const Text('Keyboard'),
      ),
      body: _MyPage(),
    ),
  ));
}

class _MyPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        TextFormField(),
        Flexible(
          child: ListView.builder(
            itemBuilder: (_, index) =>
                ListTile(title: Text(index.toRadixString(16))),
            itemCount: 40,
          ),
        )
      ],
    );
  }
}

它能解决你的问题吗?

相关问题