正如标题中已经提到的那样,当我单击TextField-Widgets时,我的键盘没有显示。我的应用程序中的每个TextField都是相同的,但并非总是如此。不幸的是,我没有使用版本控制,所以我无法找出导致它的错误。
我认为代码中没有错误,我的flutter doctor
也很好。我将放置pubspec.yaml
和build.gradle
文件,因为我更改了其中的一些内容,也许有帮助。我还将举一个文本框示例。
在我测试过的两个Android设备(都在Android 9.0上)上都会发生这种情况。我在8.1 Oreo的模拟器上试用了它,键盘似乎可以在那儿工作。
我的一种使用情况:
SliverList(
delegate: SliverChildListDelegate([
ListTile(
leading: Icon(Icons.call_to_action),
title: TextField(
decoration: InputDecoration(
labelText: "Name", border: InputBorder.none),
),
),
]),
pubspec.yaml
:
name: whatever
description: A new Flutter application.
dependencies:
flutter:
sdk: flutter
google_sign_in: ^3.2.1
googleapis: ^0.52.0
googleapis_auth: ^0.2.5+2
sqflite: ^0.12.2+1
firebase_core: ^0.2.5+1
firebase_database: ^1.0.5
barcode_scan: ^0.0.7
numberpicker: ^0.1.7
flutter_speed_dial: ^1.0.8
image_picker: ^0.4.10
chewie: ^0.8.0
sticky_headers: ^0.1.7
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/
fonts:
- family: Circular
fonts:
- asset: fonts/circular-regular.ttf
- asset: fonts/circular-bold.ttf
weight: 700
应用级build.gradle
:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.whatever"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'
项目级build.gradle
:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
答案 0 :(得分:1)
Targeting API 28似乎在物理设备上显示键盘有一些问题 提供一些链接,希望它们可以帮助您解决问题
答案 1 :(得分:0)
将我的targetSdkVersion更改为27可解决我的问题...
答案 2 :(得分:0)
如here in Github所述,从我的enableFlutterDriverExtension()
方法中删除void main()
可以为我解决这个问题。我仍在使用API 28(无需降级到27)