简体   繁体   English

键盘弹出时出现白屏

[英]White Screen Appears When Keyboard Pop Up

i am new in flutter. 我是新人。 I am having an issue but i am not sure how to debug to solve the issue. 我有问题,但我不知道如何调试来解决问题。 I try to build a signin/signup page. 我尝试建立一个登录/注册页面。 But when i try to enter value in the textfield it will just show white screen when softkey appears. 但是当我尝试在文本字段中输入值时,它会在出现软键时显示白屏。 Not sure why is this happening. 不知道为什么会这样。 Can you please help to guide me on how to fix this? 你能帮忙指导我如何解决这个问题吗? Thank you in advance. 先感谢您。

之前[![之后 ] 2 ] 2

main.dart main.dart

    import 'package:flutter/material.dart';
import 'sign_in.dart';
import 'sign_up.dart';
import 'reset_password.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.red,
        accentColor: Colors.redAccent,
      ),
      home: DefaultTabController(
        length: 3,
        child: Scaffold(
          appBar: AppBar(
            bottom: TabBar(
              tabs: [
                Tab(
                  child: Text('Sign In'),
                ),
                Tab(
                  child: Text('Sign Up'),
                ),
                Tab(
                  child: Text('Reset Password'),
                ),
              ], indicatorColor: Colors.white,
            ),
          ),
          body: TabBarView(
            children: [
              SignIn(),
              SignUp(),
              ResetPassword(),
            ],
          ),
        ),
      ),
    );
  }
}

sign_in.dart sign_in.dart

import 'package:flutter/material.dart';

class SignIn extends StatefulWidget {
  _SignInState createState() => _SignInState();
}

class _SignInState extends State<SignIn> {
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        padding: EdgeInsets.all(20.0),
        child: Form(
            child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            TextFormField(
              decoration: InputDecoration(labelText: 'Email'),
            ),
            SizedBox(height: 20.0),
            TextFormField(
              decoration: InputDecoration(labelText: 'Password'),
              obscureText: true,
            ),
            SizedBox(height: 20.0),
            RaisedButton(
              color: Colors.red,
              child: Text('Sign In',
                  style: TextStyle(fontSize: 15.0, color: Colors.white)),
              onPressed: validateAndSave,
            ),
          ],
        )),
      ),
    );
  }
}

void validateAndSave() {}

Try this code.. remove this way to define .. 试试这个代码..删除这种方式来定义..

 void main() => runApp(MaterialApp(
  debugShowCheckedModeBanner: false,
  home: MyApp(),
));

try this way i test now is working. 试试这种方式我现在测试工作。

class TestApp extends StatelessWidget{
@override
Widget build(BuildContext context) {
return MaterialApp(
home: TabViewDemo(),
);
}

}

then .. 然后 ..

 void main() {
 runApp(TestApp());

this code.. 这段代码..

 class TabViewDemo extends StatefulWidget {
 @override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<TabViewDemo> {
// This widget is the root of your application.
 @override
Widget build(BuildContext context) {
return MaterialApp(
  debugShowCheckedModeBanner: false,
  theme: ThemeData(
    primarySwatch: Colors.red,
    accentColor: Colors.redAccent,
  ),
  home: DefaultTabController(
    length: 3,
    child: Scaffold(
      appBar: AppBar(
        bottom: TabBar(
          tabs: [
            Tab(
              child: Text('Sign In'),
            ),
            Tab(
              child: Text('Sign Up'),
            ),
            Tab(
              child: Text('Reset Password'),
            ),
          ],
          indicatorColor: Colors.white,
        ),
      ),
      body: TabBarView(
        children: [
          SignIn(),
        ],
      ),
    ),
  ),
);
}
}

If you guys are having the same issue please try this solution . 如果你们有同样的问题,请尝试这个解决方案 It works for me. 这个对我有用。 Thank you. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM