1. RefreshIndicator不能下拉刷新
- list高度不够不能下拉刷新
- 解决:list属性中添加physics: new AlwaysScrollableScrollPhysics()
2. chewie播放视蒙层过暗, 背景图片在横屏时候会溢出
一步一步找源码,找到播放控制代码
import 'package:chewie/src/player_with_controls.dart';
Widget _buildPlayerWithControls(
ChewieController chewieController,
BuildContext context,
) {
return Stack(
children: <Widget>[
// if (chewieController.placeholder != null)
// chewieController.placeholder!,
if (chewieController.placeholder != null &&
!chewieController.isFullScreen) // 横屏时候不显示背景
chewieController.placeholder!,
Center(
child: AspectRatio(
aspectRatio: chewieController.aspectRatio ??
chewieController.videoPlayerController.value.aspectRatio,
child: VideoPlayer(chewieController.videoPlayerController),
),
),
if (chewieController.overlay != null) chewieController.overlay!,
if (Theme.of(context).platform != TargetPlatform.iOS)
Consumer<PlayerNotifier>(
builder: (
BuildContext context,
PlayerNotifier notifier,
Widget? widget,
) =>
AnimatedOpacity(
opacity: notifier.hideStuff ? 0.0 : 0.8,
duration: const Duration(
milliseconds: 250,
),
child: Container(
decoration: const BoxDecoration(color: Colors.transparent), // 蒙层背景颜色设置成透明
child: Container(),
),
),
),
if (!chewieController.isFullScreen)
_buildControls(context, chewieController)
else
SafeArea(
bottom: false,
child: _buildControls(context, chewieController),
),
],
);
}
3. stack中使用Column
- 要包裹一层ConstrainedBox
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: Adapt.screenW() - 20,
),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
]));
4. 键盘弹出影响布局 - 注意修改所有的scaffold
Scaffold(
resizeToAvoidBottomInset: false,
)
5. 子StatefulWidget中更新状态setState子组件不更新
- 变量命名为内部变量_items再更新列表,子组件就实现更新了
6. 页面滚动到对应位置
给对应元素设置一个key - mKey,之后Scrollable.ensureVisible
Scrollable.ensureVisible(mKey.currentContext);
tips: 感觉和前端描点差不多的意思
7. BackButton 安卓返回是一个箭头,直接修改源码
class BackButtonIcon extends StatelessWidget {
/// Creates an icon that shows the appropriate "back" image for
/// the current platform (as obtained from the [Theme]).
const BackButtonIcon({Key? key}) : super(key: key);
/// Returns the appropriate "back" icon for the given `platform`.
static IconData _getIconData(TargetPlatform platform) {
switch (platform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return Icons.arrow_back_ios; // 全部改为arrow_back_ios
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return Icons.arrow_back_ios;
}
}
@override
Widget build(BuildContext context) =>
Icon(_getIconData(Theme.of(context).platform));
}