update searchTextField

null_safety
小赖 4 years ago
parent 1d5c169e43
commit 4dbc95b492

@ -14,12 +14,13 @@ class _ExampleTextFiledState extends State<ExampleTextFiled> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ASScaffold( return ASScaffold(
title: '文本框 TextFiled', title: '文本框 TextFiled',
appBarBottom: ASSearchTextField( backgroundColor: kForegroundColor,
body: ListView(
children: [
ASSearchTextField(
controller: _controller, controller: _controller,
hintText: '搜索', hintText: '搜索',
), ),
body: ListView(
children: [
ASSearchTextField.button( ASSearchTextField.button(
hintText: '搜索', hintText: '搜索',
onPressed: () {}, onPressed: () {},

@ -37,6 +37,9 @@ class ASScaffold extends StatefulWidget {
/// `AppBar` appBar /// `AppBar` appBar
final Widget appBar; final Widget appBar;
///
final Color backgroundColor;
ASScaffold({ ASScaffold({
Key key, Key key,
this.title, this.title,
@ -46,6 +49,7 @@ class ASScaffold extends StatefulWidget {
this.appBarBottom, this.appBarBottom,
this.endDrawer, this.endDrawer,
this.appBar, this.appBar,
this.backgroundColor = kBackgroundColor,
}) : super(key: key); }) : super(key: key);
@override @override
@ -57,7 +61,7 @@ class _ASScaffoldState extends State<ASScaffold> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
endDrawer: widget.endDrawer, endDrawer: widget.endDrawer,
backgroundColor: kBackgroundColor, backgroundColor: widget.backgroundColor,
bottomNavigationBar: widget.bottomNavigationBar, bottomNavigationBar: widget.bottomNavigationBar,
appBar: widget.title == null && appBar: widget.title == null &&
widget.appBar == null && widget.appBar == null &&
@ -68,9 +72,6 @@ class _ASScaffoldState extends State<ASScaffold> {
brightness: Brightness.light, brightness: Brightness.light,
backgroundColor: kForegroundColor, backgroundColor: kForegroundColor,
elevation: 0, elevation: 0,
toolbarHeight: widget.title == null && widget.appBar == null
? widget.appBarBottom.preferredSize.height + 2.0
: null,
leading: widget.leading ?? ASBackButton(), leading: widget.leading ?? ASBackButton(),
centerTitle: true, centerTitle: true,
title: DefaultTextStyle( title: DefaultTextStyle(

@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
///TextFiled ///TextFiled
class ASSearchTextField extends StatefulWidget implements PreferredSizeWidget { class ASSearchTextField extends StatefulWidget {
ASSearchTextField({ ASSearchTextField({
Key key, Key key,
this.controller, this.controller,
@ -54,9 +54,6 @@ class ASSearchTextField extends StatefulWidget implements PreferredSizeWidget {
@override @override
_ASSearchTextFieldState createState() => _ASSearchTextFieldState(); _ASSearchTextFieldState createState() => _ASSearchTextFieldState();
@override
Size get preferredSize => Size.fromHeight(42.w);
} }
class _ASSearchTextFieldState extends State<ASSearchTextField> { class _ASSearchTextFieldState extends State<ASSearchTextField> {

Loading…
Cancel
Save