Orientation Builder- Flutter 如何在一个代码库中添加不同的 body
Orientation Builder- Flutter how to add different body within one code base
我想展示的图片有不同的身体,
我想对一个代码使用 Orientation builder 来显示肖像,另一个代码显示风景,我该怎么做?
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)
}
},
);
我想展示的图片有不同的身体,
我想对一个代码使用 Orientation builder 来显示肖像,另一个代码显示风景,我该怎么做?
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)
}
},
);