🐛 Trying to fix app scaffold focus conflict

This commit is contained in:
2026-01-07 01:52:25 +08:00
parent d96629a7f1
commit 3e7007f58f

View File

@@ -357,44 +357,34 @@ class AppScaffold extends HookConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final focusNode = useFocusNode();
useEffect(() {
focusNode.requestFocus();
return null;
}, []);
final appBarHeight = appBar?.preferredSize.height ?? 0; final appBarHeight = appBar?.preferredSize.height ?? 0;
final safeTop = MediaQuery.of(context).padding.top; final safeTop = MediaQuery.of(context).padding.top;
final noBackground = isNoBackground ?? isWideScreen(context); final noBackground = isNoBackground ?? isWideScreen(context);
final builtWidget = Focus( final builtWidget = Scaffold(
focusNode: focusNode, extendBody: extendBody ?? true,
child: Scaffold( extendBodyBehindAppBar: true,
extendBody: extendBody ?? true, backgroundColor: Colors.transparent,
extendBodyBehindAppBar: true, body: Column(
backgroundColor: Colors.transparent, children: [
body: Column( IgnorePointer(
children: [ child: SizedBox(
IgnorePointer( height: appBar != null ? appBarHeight + safeTop : 0,
child: SizedBox(
height: appBar != null ? appBarHeight + safeTop : 0,
),
), ),
if (body != null) Expanded(child: body!), ),
], if (body != null) Expanded(child: body!),
), ],
appBar: appBar,
bottomNavigationBar: bottomNavigationBar,
bottomSheet: bottomSheet,
drawer: drawer,
endDrawer: endDrawer,
floatingActionButton: floatingActionButton,
floatingActionButtonAnimator: floatingActionButtonAnimator,
onDrawerChanged: onDrawerChanged,
onEndDrawerChanged: onEndDrawerChanged,
), ),
appBar: appBar,
bottomNavigationBar: bottomNavigationBar,
bottomSheet: bottomSheet,
drawer: drawer,
endDrawer: endDrawer,
floatingActionButton: floatingActionButton,
floatingActionButtonAnimator: floatingActionButtonAnimator,
onDrawerChanged: onDrawerChanged,
onEndDrawerChanged: onEndDrawerChanged,
); );
return noBackground return noBackground