【发布时间】:2022-01-19 04:26:29
【问题描述】:
我尝试返回上一个屏幕。但是 UI 只显示黑色背景,并且只发生在这个屏幕上。我尝试了Navigator.pop(context); 和Navigator.of(context).pop();。
这是我的代码:
return MaterialApp(
home: SafeArea(
child: Scaffold(
body: BlocBuilder<TimeKeepingCubit, TimeKeepingState>(
builder: (context, state)
{
var scale = 1.0;
if (state.controller != null){
var camera = state.controller!.value;
// fetch screen size
final size = MediaQuery.of(context).size;
// calculate scale depending on screen and camera ratios
// this is actually size.aspectRatio / (1 / camera.aspectRatio)
// because camera preview size is received as landscape
// but we're calculating for portrait orientation
var scale = size.aspectRatio * camera.aspectRatio;
// to prevent scaling down, invert the value
if (scale < 1) scale = 1 / scale;
}
return Stack(
children: [
state.controller == null ? SizedBox() : Center(
child: Transform.scale(
scale: scale,
child: Center(
child: CameraPreview(state.controller!),
),
),
),
Visibility(
visible: state is TimeKeepingLoading,
child: Center(
child: Container(
width: 68,
height: 68,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: AppColors.whiteE0E0E0),
child: CupertinoActivityIndicator())
),
),
buildAlignScafoldScan(),
Positioned(
top: 0,
left: 0,
child: IconButton(
icon: SvgPicture.asset(Res.ic_back_left_blue),
onPressed: () {
Navigator.pop(context);
// Navigator.of(context).pop();
},
),
),
【问题讨论】:
标签: flutter navigation flutter-layout navigator