You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've set the page to always be in portrait position. When I enable the video in fullscreen mode it goes to a new page with the video in fullscreen in the landscape position, so far so good!
The problem is when I exit the fullscreen mode and go back to the previous screen. The page is no longer set in portrait mode, it follows the orientation of the cell phone. When I go back once more and now I go to the home screen which is also set in portrait mode and I go to the screen where the video is, it goes back to being set in portrait mode.
Hi! I have a strange bug!
I've set the page to always be in portrait position. When I enable the video in fullscreen mode it goes to a new page with the video in fullscreen in the landscape position, so far so good!
The problem is when I exit the fullscreen mode and go back to the previous screen. The page is no longer set in portrait mode, it follows the orientation of the cell phone. When I go back once more and now I go to the home screen which is also set in portrait mode and I go to the screen where the video is, it goes back to being set in portrait mode.
Follow the code:
`import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hive/hive.dart';
import 'package:provider/provider.dart';
import 'package:share_plus/share_plus.dart';
import '../blocs/blocs.dart';
import '../config/config.dart';
import '../models/models.dart';
import '../services/services.dart';
import '../widgets/widgets.dart';
class VideoArticleDetails extends StatefulWidget {
final Article article;
const VideoArticleDetails({Key? key, required this.article}) : super(key: key);
@OverRide
_VideoArticleDetailsState createState() => _VideoArticleDetailsState();
}
class _VideoArticleDetailsState extends State {
double _rightPaddingValue = 100;
var scaffoldKey = GlobalKey();
Future _handleShare() async {
Share.share(widget.article.link!);
}
@OverRide
void initState() {
super.initState();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
Future.delayed(const Duration(milliseconds: 0)).then((value) => context.read().showLoadedAds());
Future.delayed(const Duration(milliseconds: 100)).then((value) => setState(() {
_rightPaddingValue = 10;
}));
}
@OverRide
void dispose() {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
super.dispose();
}
@OverRide
Widget build(BuildContext context) {
final bookmarkedList = Hive.box(Constants.bookmarkTag);
return Scaffold(
backgroundColor: Theme.of(context).backgroundColor,
key: scaffoldKey,
appBar: _appBar(),
body: SafeArea(
bottom: true,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
VideoPlayerPod(videoUrl: widget.article.video!, videoType: 'youtube'),
Expanded(
flex: 1,
child: SingleChildScrollView(
child: Column(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 0),
child: Column(
children: [
Row(
children: [
Container(
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Theme.of(context).colorScheme.onBackground,
),
child: AnimatedPadding(
duration: const Duration(milliseconds: 500),
padding: EdgeInsets.only(left: _rightPaddingValue, right: _rightPaddingValue, top: 5, bottom: 5),
child: Text(
widget.article.category!,
style: TextStyle(fontSize: 15, color: Theme.of(context).colorScheme.primary, fontWeight: FontWeight.w600),
),
),
),
const Spacer(),
BookmarkIcon(
bookmarkedList: bookmarkedList,
article: widget.article,
iconSize: 22,
iconColor: Colors.blueGrey,
normalIconColor: Colors.grey,
),
],
),
],
),
),
const SizedBox(
height: 15,
),
Padding(
padding: const EdgeInsets.only(left: 20, bottom: 12),
child: Row(
children: [
const SizedBox(
width: 5,
),
Text(
widget.article.timeAgo!,
style: TextStyle(
fontSize: 14,
color: Theme.of(context).colorScheme.secondary,
),
),
],
),
),
const SizedBox(
width: 15,
),
const SizedBox(
width: 10,
),
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Text(
AppService.getNormalText(widget.article.title!),
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, letterSpacing: -0.6, wordSpacing: 1),
),
),
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Divider(
color: Theme.of(context).primaryColor,
endIndent: 280,
thickness: 2,
),
),
const SizedBox(
height: 5,
),
HtmlBody(content: widget.article.content!, isVideoEnabled: false, isImageEnabled: true, isIframeVideoEnabled: true),
const SizedBox(
height: 20,
),
],
),
RelatedArticles(postId: widget.article.id, catId: widget.article.catId),
const SizedBox(
height: 50,
),
],
),
),
),
AdsConfig.isAdsEnabled == true ? const BannerAdsWidget() : Container(),
],
),
),
);
//});
}
AppBar _appBar() {
return AppBar(
automaticallyImplyLeading: false,
toolbarHeight: 45,
leading: IconButton(
onPressed: () => Navigator.pop(context),
icon: const Icon(
Icons.arrow_back_ios_sharp,
size: 20,
),
),
actions: [
Padding(
padding: const EdgeInsets.only(right: 6.0),
child: IconButton(
onPressed: () => _handleShare(),
icon: const Icon(
Icons.share,
size: 20,
),
),
),
],
);
}
}
`
`import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:pod_player/pod_player.dart';
class VideoPlayerPod extends StatefulWidget {
final String videoUrl;
final String videoType;
final String? thumbnailUrl;
const VideoPlayerPod({Key? key, required this.videoUrl, required this.videoType, this.thumbnailUrl}) : super(key: key);
@OverRide
State createState() => _VideoPlayerWidgetState();
}
class _VideoPlayerWidgetState extends State {
late final PodPlayerController controller;
@OverRide
void initState() {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
controller = PodPlayerController(
playVideoFrom: widget.videoType == 'network'
? PlayVideoFrom.network(widget.videoUrl)
: widget.videoType == 'vimeo'
? PlayVideoFrom.vimeo(widget.videoUrl)
: PlayVideoFrom.youtube(widget.videoUrl),
podPlayerConfig: const PodPlayerConfig(
autoPlay: false,
isLooping: false,
))
..initialise();
super.initState();
}
@OverRide
void dispose() {
controller.dispose();
SystemChrome.setPreferredOrientations(DeviceOrientation.values);
super.dispose();
}
@OverRide
Widget build(BuildContext context) {
return PodVideoPlayer(
controller: controller,
alwaysShowProgressBar: true,
videoThumbnail: widget.thumbnailUrl == null ? null : DecorationImage(fit: BoxFit.cover, image: CachedNetworkImageProvider(widget.thumbnailUrl!)),
);
}
}`
The text was updated successfully, but these errors were encountered: