i hope the title is enough to understand my problem is, story line: When the user click full screen. the video automatic landscape. How? please help me
Container(
child: Column(children: <Widget>[
Expanded(
child: Container(
margin: const EdgeInsets.all(0.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.blueAccent)),
child: InAppWebView(
initialUrl:
"https://ip-address/play.html?name=123456789",
initialHeaders: {},
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onLoadStart:
(InAppWebViewController controller, String url) {
setState(() {
this.url = url;
});
},
onLoadStop: (InAppWebViewController controller,
String url) async {
setState(() {
this.url = url;
});
},
onProgressChanged:
(InAppWebViewController controller, int progress) {
setState(() {
this.progress = progress / 100;
});
},
),
),
),
])),
Solution 1: Alexey Inkin
You can use JavaScript channel to get notifications from the web view. See a section on channels here: https://medium.com/flutter-community/inappwebview-the-real-power-of-webviews-in-flutter-c6d52374209d
Then in your HTML/JavaScript, listen to full the screen event on your video object and send it to the JavaScript channel to be handled in Flutter app.
Solution 2: Tasnuva Tavasum oshin
dependencies: auto_orientation: ^2.0.0
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:auto_orientation/auto_orientation.dart';
void main() {
runApp(
AutoOrientationDemo(),
);
}
class AutoOrientationDemo extends StatefulWidget {
AutoOrientationDemo({this.title = 'Auto Orientation Demo'});
final String title;
@override
State<StatefulWidget> createState() {
return _AutoOrientationDemoState();
}
}
class _AutoOrientationDemoState extends State<AutoOrientationDemo> {
TargetPlatform? _platform;
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: widget.title,
theme: ThemeData.light().copyWith(
platform: _platform ?? Theme.of(context).platform,
),
home: Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: TextButton(
onPressed: () {
AutoOrientation.portraitDownMode();
},
child: Padding(
child: Text("Portrait UPSIDE Down"),
padding: EdgeInsets.symmetric(vertical: 16.0),
),
),
),
Expanded(
child: TextButton(
onPressed: () {
AutoOrientation.fullAutoMode();
},
child: Padding(
child: Text("All modes"),
padding: EdgeInsets.symmetric(vertical: 16.0),
),
),
),
],
),
Row(
children: <Widget>[
Expanded(
child: TextButton(
onPressed: () {
AutoOrientation.landscapeAutoMode();
},
child: Padding(
child: Text("Landscape auto"),
padding: EdgeInsets.symmetric(vertical: 16.0),
),
),
),
Expanded(
child: TextButton(
onPressed: () {
AutoOrientation.portraitAutoMode();
},
child: Padding(
child: Text("Portrait auto"),
padding: EdgeInsets.symmetric(vertical: 16.0),
),
),
),
],
),
Row(
children: <Widget>[
Expanded(
child: TextButton(
onPressed: () {
AutoOrientation.landscapeLeftMode();
},
child: Padding(
child: Text("Landscape left mode"),
padding: EdgeInsets.symmetric(vertical: 16.0),
),
),
),
Expanded(
child: TextButton(
onPressed: () {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
AutoOrientation.landscapeRightMode();
},
child: Padding(
child: Text("Landscape right mode"),
padding: EdgeInsets.symmetric(vertical: 16.0),
),
),
),
],
),
Row(
children: <Widget>[
Expanded(
child: TextButton(
onPressed: () {
AutoOrientation.portraitUpMode();
},
child: Padding(
child: Text("Portrait up mode"),
padding: EdgeInsets.symmetric(vertical: 16.0),
),
),
),
Expanded(
child: TextButton(
onPressed: () {
AutoOrientation.portraitDownMode();
},
child: Padding(
child: Text("Portrait down mode"),
padding: EdgeInsets.symmetric(vertical: 16.0),
),
),
),
],
)
],
),
),
);
}
}
This Will Help You For Auto Screen Orientation based on your content