提交 5ff3495c authored 作者: shixiaochen's avatar shixiaochen

1、设置SafeArea

上级 d170917d
import 'dart:io'; import 'dart:io';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'state_layout.dart'; import 'state_layout.dart';
/// 封装下拉刷新与加载更多 /// 封装下拉刷新与加载更多
...@@ -146,8 +148,7 @@ class _MyListViewPublicState extends State<MyListViewPublic> { ...@@ -146,8 +148,7 @@ class _MyListViewPublicState extends State<MyListViewPublic> {
), ),
), ),
); );
return SafeArea( return NotificationListener(
child: NotificationListener(
onNotification: (ScrollNotification note) { onNotification: (ScrollNotification note) {
/// 确保是垂直方向滚动,且滑动至底部 /// 确保是垂直方向滚动,且滑动至底部
if (note.metrics.pixels == note.metrics.maxScrollExtent && if (note.metrics.pixels == note.metrics.maxScrollExtent &&
...@@ -157,7 +158,6 @@ class _MyListViewPublicState extends State<MyListViewPublic> { ...@@ -157,7 +158,6 @@ class _MyListViewPublicState extends State<MyListViewPublic> {
return true; return true;
}, },
child: child, child: child,
),
); );
} }
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:keyboard_actions/keyboard_actions.dart'; import 'package:keyboard_actions/keyboard_actions.dart';
import 'my_app_bar.dart'; import 'my_app_bar.dart';
import 'my_scroll_view.dart'; import 'my_scroll_view.dart';
...@@ -34,23 +35,18 @@ class MyScaffold extends StatelessWidget { ...@@ -34,23 +35,18 @@ class MyScaffold extends StatelessWidget {
return Scaffold( return Scaffold(
appBar: appBar ?? MyPageAppBar(title: title), appBar: appBar ?? MyPageAppBar(title: title),
backgroundColor: backgroundColor ?? const Color(0xFFf2f3f3), backgroundColor: backgroundColor ?? const Color(0xFFf2f3f3),
body: _getBodyWidget(), body: SafeArea(
floatingActionButton: floatingActionButton, child: body ??
); MyScrollView(
}
_getBodyWidget() {
if(body != null) {
return SafeArea(child: body!);
} else {
return MyScrollView(
padding: padding, padding: padding,
bottomButton: bottomButton, bottomButton: bottomButton,
crossAxisAlignment: crossAxisAlignment, crossAxisAlignment: crossAxisAlignment,
keyboardConfig: keyboardConfig, keyboardConfig: keyboardConfig,
children: children ?? [], children: children ?? [],
),
),
floatingActionButton: floatingActionButton,
); );
} }
}
} }
...@@ -71,7 +71,7 @@ class MyScrollView extends StatelessWidget { ...@@ -71,7 +71,7 @@ class MyScrollView extends StatelessWidget {
contents = Column( contents = Column(
children: <Widget>[ children: <Widget>[
Expanded(child: contents), Expanded(child: contents),
SafeArea(child: bottomButton!) bottomButton!
], ],
); );
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论