import 'package:flutter/material.dart';
import '../widgets/diagonally_cut_colored_image.dart';
import '../app_settings.dart';
import '../style.dart';
import 'package:webview_flutter/webview_flutter.dart';
import '../widgets/appbar_search.dart';
import '../strings.dart';
import 'package:path_provider/path_provider.dart';
import 'package:flutter/services.dart';
import 'dart:collection';
import 'dart:async';
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'dart:io' show Platform;
class LivePage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new LivePageState();
}
}
class LivePageState extends State<LivePage> {
BuildContext _ctx;
static const BACKGROUND_IMAGE = 'assets/sobreHeader.jpg';
//static const url = "https://www.riodasostras.rj.gov.br/live-app-jazz-e-blues-2019/";
static const url = "https://appsescverao.firebaseapp.com/#/livePublic";
WebViewController _controller;
Size preferredSize;
bool isFullscreen = false;
bool isVisibilityFullscreenBtn = true;
Timer _timer;
Widget _buildAvatar() {
return Container(
width: double.infinity,
height: 120,
padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
child: Image.asset('assets/logoJazz.png'),
);
}
Widget _header(BuildContext context) {
var theme = Theme.of(context);
var textTheme = theme.textTheme;
var screenWidth = MediaQuery.of(context).size.width;
return Stack(
children: <Widget>[
Container(
child: Image.asset(
BACKGROUND_IMAGE,
width: screenWidth,
height: 200,
fit: BoxFit.cover,
),
),
Container(
width: screenWidth,
height: 200,
color: Color.fromRGBO(30, 97, 145, .7),
),
Align(
alignment: FractionalOffset.bottomCenter,
heightFactor: 1.4,
child: Column(
children: <Widget>[
_buildAvatar(),
],
),
),
Positioned(
top: 26.0,
left: 4.0,
child: BackButton(
color: Colors.white,
),
),
],
);
}
background() {
return Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
//color: Color.fromRGBO(50, 50, 50, 1)
image: DecorationImage(
image: AssetImage('assets/background.png'),
fit: BoxFit.cover,
),
),
child: Container(
//color: Color.fromRGBO(103, 189, 211, 0.5),
),
);
}
appBar() {
return SearchAppBar(
showSearch: false,
title: AppStrings.liveTitle,
onKeypress: (searchString) {},
);
}
List<Widget> _buildContent() {
var l = new List<Widget>();
//background page
l.add(background());
//lista
l.add(
Positioned(
top: 0,
left: 0.0,
right: 0.0,
bottom: 0,
child: Scaffold(
appBar: !isFullscreen ? appBar() : null,
backgroundColor: Colors.transparent,
body: GestureDetector(
onDoubleTap: () {
print("sad");
setState(() {
isVisibilityFullscreenBtn = true;
hideFullscreenBtn();
});
},
child: WebView(
onWebViewCreated: (WebViewController webViewController) {
_controller = webViewController;
},
javascriptMode: JavascriptMode.unrestricted,
initialUrl: url,
),
),
),
),
);
if (Platform.isAndroid) {
if (isVisibilityFullscreenBtn) {
l.add(
Positioned(
bottom: 30,
right: 30,
child: Material(
color: Color.fromRGBO(255, 255, 255, 0.5),
borderRadius: BorderRadius.all(Radius.circular(50)),
child: InkWell(
child: Container(
padding: EdgeInsets.fromLTRB(16, 16, 16, 16),
child: Icon(Icons.fullscreen),
),
onTap: () {
setState(() {
if (!isFullscreen) {
isFullscreen = true;
SystemChrome.setEnabledSystemUIOverlays([]);
hideFullscreenBtn();
} else {
isFullscreen = false;
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
}
});
}),
)),
);
}
}
return l;
}
hideFullscreenBtn() async {
_timer = new Timer(const Duration(milliseconds: 5000), () {
setState(() {
if (isFullscreen) isVisibilityFullscreenBtn = false;
});
});
}
@override
Widget build(BuildContext context) {
_ctx = context;
return Stack(
fit: StackFit.expand,
children: _buildContent(),
);
}
}
i'm having this problem with my app, when i full screen the app in a view with a scaffold and a webview widget playing a video embed from facebook the app closes unexpectedly, the phone is a xiaomi redmi note 6.
pubspec.yaml
code sample
logs