import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:lszlgl/config/colors.dart'; import 'package:lszlgl/config/pics.dart'; export 'package:lszlgl/config/pics.dart'; export 'package:lszlgl/router/my_navigator.dart'; export 'package:lszlgl/router/my_router.dart'; export 'package:lszlgl/ext/value_notifier_ext.dart'; abstract class BaseState extends State { EdgeInsets get mediaPadding => MediaQuery.of(context).padding; double getBottomPadding(double defaultValue) => mediaPadding.bottom != 0 ? mediaPadding.bottom : defaultValue; /// 隐藏软键盘 void hideKeyboard() { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) { FocusManager.instance.primaryFocus?.unfocus(); } } AppBar myAppBar({ String title = '', String? titleIcon, bool autoLeading = true, PreferredSizeWidget? bottom, double? toolbarHeight, List? actions, Color? naviBarColor, Brightness? naviBarBrightness, }) { return AppBar( title: Text(title), bottom: bottom, automaticallyImplyLeading: autoLeading, toolbarHeight: toolbarHeight, actions: actions, systemOverlayStyle: SystemUiOverlayStyle.light.copyWith( systemNavigationBarColor: naviBarColor ?? MyColor.c_background, systemNavigationBarIconBrightness: naviBarBrightness ?? Brightness.dark, ), ); } /// 带背景图的Scaffold Widget myScaffold({required Widget child}) { return Scaffold( body: Stack( children: [ SizedBox(width: double.infinity, child: Image.asset(imgHomeTopBg)), child, ], ), ); } }