最近遇到一个问题,当键盘显示在聚焦TextField时,应用程序将键盘的底部填充两倍。这取代了TabBar并扩展了ListViews。一旦我专注于TextField,它就会影响所有显示。
当我将Gradle更新为4.1以尝试使用google_sign_in插件时,似乎出现了问题。
以下是我的main_screen.dart
import 'package:flutter/material.dart';
import '../Utils/lang.dart';
import 'themes.dart';
import 'page_dashboard.dart';
import 'page_explore.dart';
import 'page_inbox.dart';
import 'page_new_quest.dart';
import '../fields.dart';
import 'page_chat_conversation.dart';
import 'page_log_in.dart';
import '../fab_dialer/flutter_fab_dialer.dart';
import 'welfare_overlay.dart';
import 'page_log_in_test.dart';
import 'page_splash.dart';
enum Pages {Newsfeed, Dashboard, Explore, Inbox}
enum Menu {AboutUs, LogOff}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Pay It Forward',
theme: new ThemeData(
primarySwatch: Colors.cyan,
),
home: new MyHomePage(title: 'Pay It Forward'),
routes: <String, WidgetBuilder> {
'/newQuest': (BuildContext context) => new PageNewQuest(),
'/conversation': (BuildContext context) => new PageChatConversation(),
},
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Pages _currentPage = Pages.Dashboard;
@override
Widget build(BuildContext context) {
ScreenHeight = MediaQuery.of(context).size.height;
BottomNavigationBar bottomNavigationBar = new BottomNavigationBar(
type: BottomNavigationBarType.shifting,
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(icon: new Icon(Icons.all_inclusive), title: new Text(PIFLocale.NEWSFEED), backgroundColor: Colors.cyan),
new BottomNavigationBarItem(icon: new Icon(Icons.home), title: new Text(PIFLocale.DASHBOARD), backgroundColor: Colors.lightGreen),
new BottomNavigationBarItem(icon: new Icon(Icons.explore), title: new Text(PIFLocale.EXPLORE), backgroundColor: Colors.amber),
new BottomNavigationBarItem(icon: new Icon(Icons.email), title: new Text(PIFLocale.INBOX), backgroundColor: Colors.orange),
],
onTap: (i) => setState( () => _currentPage = Pages.values[i]),
currentIndex: _currentPage.index
);
List<FabMiniMenuItem> floatingActionButtonList = new List();
floatingActionButtonList.add(new FabMiniMenuItem(
onPressed: (){Navigator.of(context).pushNamed('/newQuest');},
textColor: Colors.white,
chipColor: Colors.redAccent,
fabColor: Colors.white,
icon: new Icon(Icons.add, color: Colors.redAccent),
elevation: 4.0,
text: "New Request",
tooltip: "Hello",
heroTag: "Abc"
));
floatingActionButtonList.add(new FabMiniMenuItem(
onPressed: (){},
textColor: Colors.white,
chipColor: Colors.redAccent,
fabColor: Colors.white,
icon: new Icon(Icons.add, color: Colors.redAccent),
elevation: 4.0,
text: "New Offer",
heroTag: "def"
));
Scaffold mainScaffold = new Scaffold(
body: _getNewSubPage(),
//drawer: new Drawer(child: new DrawerContent()),
floatingActionButton: new FabDialer(
floatingActionButtonList,
Colors.redAccent,
new Icon(Icons.add),
),
bottomNavigationBar: bottomNavigationBar,
);
return new WillPopScope(
child: mainScaffold,
onWillPop: () {
if (_currentPage != Pages.Dashboard){
setState(() => _currentPage = Pages.Dashboard);
} else{
return showDialog(
context: context,
child: new AlertDialog(
title: new Text('Byeeee?'),
content: new Text('Are you sure you want to quit? \n真的要離開嗎?'),
actions: <Widget>[
new FlatButton(
onPressed: () => Navigator.of(context).pop(false),
child: new Text('No'),
),
new FlatButton(
onPressed: () => Navigator.of(context).pop(true),
child: new Text('Yes'),
),
],
),
) ?? false;
}
}
);
}
Widget _getNewSubPage(){
Widget child; // WELFARE
switch (_currentPage)
{
case Pages.Newsfeed:
child = new PageSplash();
break;
case Pages.Dashboard:
child = new PageDashboard();
break;
case Pages.Explore:
child = new PageExplore();
break;
case Pages.Inbox:
child = new PageInbox();
break;
default:
child = new PageDashboard();
}
/*
if (_currentPage != Pages.Dashboard){
return new Stack(
children:[
child,
new WelfareOverlay(),
]
);
} else {
return child;
}*/
return child;
}
}
/*Widget PopUpMenu<Menu>() {
return new PopUpMenuButton<Menu>(
)
}*/
这是我用来演示的测试页
import 'package:flutter/material.dart';
import 'themes.dart';
class PageSplash extends StatefulWidget{
@override
State createState() {
return new PageSplashState();
}
}
class PageSplashState extends State<PageSplash> {
@override
Widget build(BuildContext context) {
return new Container(
child: new TextField(),
);
}
}
非常感谢你。