From 2b6c2f36bf1e9264efbc7389a563ece6ce8b5cb9 Mon Sep 17 00:00:00 2001 From: Weller <1812208341@qq.com> Date: Fri, 16 Oct 2020 10:48:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AE=A2=E5=8D=95=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/orders_page/order_search_page.dart | 59 +++++++++++++------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/lib/pages/orders_page/order_search_page.dart b/lib/pages/orders_page/order_search_page.dart index 363fac3..43aee78 100644 --- a/lib/pages/orders_page/order_search_page.dart +++ b/lib/pages/orders_page/order_search_page.dart @@ -1,7 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:zhiying_comm/zhiying_comm.dart'; import 'package:zhiying_base_widget/widgets/empty/empty_widget.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; // 订单搜索页面 class OrderSearchPage extends StatefulWidget { @@ -18,14 +18,26 @@ class _OrderSearchPageState extends State { super.initState(); } + @override + void dispose() { + _keywordController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { - return Scaffold( - appBar: _createNav(), - body: SafeArea( - child: Container(width: double.infinity, - height: double.infinity, - child: Center(child: EmptyWidget())), + return GestureDetector( + onTap: () { + FocusScope.of(context).requestFocus(FocusNode()); + }, + child: Scaffold( + appBar: _createNav(), + body: SafeArea( + child: Container( + width: double.infinity, + height: double.infinity, + child: Center(child: EmptyWidget())), + ), ), ); } @@ -42,19 +54,19 @@ class _OrderSearchPageState extends State { backgroundColor: Colors.white, leading: Navigator.canPop(context) ? GestureDetector( - child: Container( - padding: EdgeInsets.zero, - child: Icon( - Icons.arrow_back_ios, - size: 20, - ), - ), - onTap: () { - if (Navigator.canPop(context)) { - Navigator.pop(context); - } - }, - ) + child: Container( + padding: EdgeInsets.zero, + child: Icon( + Icons.arrow_back_ios, + size: 20, + ), + ), + onTap: () { + if (Navigator.canPop(context)) { + Navigator.pop(context); + } + }, + ) : Container(), middle: Container( height: 32, @@ -68,6 +80,8 @@ class _OrderSearchPageState extends State { placeholderStyle: TextStyle(color: Color(0xff999999), fontSize: 14), controller: _keywordController, style: TextStyle(fontSize: 14, color: Color(0xff333333)), + textInputAction: TextInputAction.search, + onSubmitted: _search, ), ), trailing: Container( @@ -83,9 +97,14 @@ class _OrderSearchPageState extends State { ), onPressed: () { Logger.debug(_keywordController.text); + _search(_keywordController.text); }, ), ), ); } + + void _search(String keyword) { + FocusScope.of(context).requestFocus(FocusNode()); + } }