how to avoid orientation changes when keyboard is opened with OrientationBuilder in Flutter ?
Indeed when the keyboard appears the orientation property of OrientationBuilder changes to landscape even if we don't rotate the phone.
Image:
Code :
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: OrientationBuilder(builder: (context, orientation) {
var _children = [
Expanded(
child: Center(
child: Text('Orientation : $orientation',
textAlign: TextAlign.center))),
Flexible(
child: Container(color: Colors.blue, child: TextField())),
Flexible(child: Container(color: Colors.yellow)),
];
if (orientation == Orientation.portrait) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: _children);
} else {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: _children);
}
})),
);
}
}

