Переглянути джерело

登录页点击空白处收起键盘

Groot 6 місяців тому
батько
коміт
1fe216a863
1 змінених файлів з 44 додано та 38 видалено
  1. 44 38
      lib/module/login/login_page.dart

+ 44 - 38
lib/module/login/login_page.dart

@@ -29,46 +29,52 @@ class LoginPage extends BasePage<LoginController> {
 
   @override
   Widget buildBody(BuildContext context) {
-    return Stack(
-      children: [
-        AspectRatio(
-            aspectRatio: 360 / 285,
-            child: Assets.images.bgLoginHeadContainer
-                .image(width: double.infinity)),
-        buildLoginHeader(),
-        SafeArea(
-          child: Column(
-            children: [
-              SizedBox(height: 150.5.w),
-              Expanded(
-                child: Container(
-                  width: double.infinity,
-                  height: double.infinity,
-                  decoration: BoxDecoration(
-                    color: ColorName.white,
-                    borderRadius: BorderRadius.only(
-                      topLeft: Radius.circular(18.w),
-                      topRight: Radius.circular(18.w),
+    return GestureDetector(
+      onTap: () {
+        // 点击空白处关闭键盘
+        FocusScope.of(context).unfocus();
+      },
+      child: Stack(
+        children: [
+          AspectRatio(
+              aspectRatio: 360 / 285,
+              child: Assets.images.bgLoginHeadContainer
+                  .image(width: double.infinity)),
+          buildLoginHeader(),
+          SafeArea(
+            child: Column(
+              children: [
+                SizedBox(height: 150.5.w),
+                Expanded(
+                  child: Container(
+                    width: double.infinity,
+                    height: double.infinity,
+                    decoration: BoxDecoration(
+                      color: ColorName.white,
+                      borderRadius: BorderRadius.only(
+                        topLeft: Radius.circular(18.w),
+                        topRight: Radius.circular(18.w),
+                      ),
+                    ),
+                    child: Column(
+                      children: [
+                        SizedBox(height: 27.w),
+                        buildPhoneTextFiled(),
+                        SizedBox(height: 12.w),
+                        buildCodeTextFiled(),
+                        SizedBox(height: 10.w),
+                        buildPrivacyTxt(),
+                        SizedBox(height: 148.h),
+                        buildLoginBtn(),
+                      ],
                     ),
                   ),
-                  child: Column(
-                    children: [
-                      SizedBox(height: 27.w),
-                      buildPhoneTextFiled(),
-                      SizedBox(height: 12.w),
-                      buildCodeTextFiled(),
-                      SizedBox(height: 10.w),
-                      buildPrivacyTxt(),
-                      SizedBox(height: 148.h),
-                      buildLoginBtn(),
-                    ],
-                  ),
-                ),
-              )
-            ],
-          ),
-        )
-      ],
+                )
+              ],
+            ),
+          )
+        ],
+      ),
     );
   }