方向生成器-Flutter如何在一个代码库中添加不同的主体



我想显示的图像有不同的主体,

我想对其中一个代码使用方向生成器来显示肖像,另一个代码显示风景,我该怎么做?

child: OrientationBuilder(
builder: (BuildContext context, Orientation orientation) {
return Orientation.landscape
body: Center(
child: InteractiveViewer(
maxScale: styling.interactiveviewermaxscale,
minScale: styling.interactiveviewerminscale,
child: Container(
constraints: BoxConstraints.expand(),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(quranImagepg), fit: BoxFit.fill)),
else 
return : Portrait: 
body: SingleChildScrollView(
child: AspectRatio(
// width / height
aspectRatio: 0.7,
// child: Container(
// width: styling.singlechildScrollviewWidthsidetoside,
// height: styling.singlechildScrollviewHeightsidetoside,
// width: width,
// height: height * 5,
// width: 1500,
// height: 1200,
child: InteractiveViewer(
maxScale: styling.interactiveviewermaxscale,
minScale: styling.interactiveviewerminscale,
child: Stack(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
children: <Widget>[
new Container(
child: new Image.asset(quranImagepg,
// fit: BoxFit.fitWidth,
fit: BoxFit.cover
// color: Colors.purpleAccent,
// colorBlendMode: BlendMode.,
),
),
...
child:OrientationBuilder(
builder: (context, orientation) {
if (orientation == Orientation.landscape){
return Center(... //rest of your landscape code)
}else{
return SingleChildScrollView( ... //rest of you portrait code)
}
},
);

最新更新