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

1、设置SafeArea

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