Skip to content

Commit

Permalink
Fix #10 , update model_viewer_plus_mobile.dart
Browse files Browse the repository at this point in the history
_proxy null check and setState() for it
  • Loading branch information
Foldblade committed Mar 13, 2022
1 parent 62aba9d commit 6b4bb1f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/src/model_viewer_plus_mobile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ class ModelViewerState extends State<ModelViewer> {
@override
Widget build(final BuildContext context) {
if (_proxy == null) {
return Center(
child: CircularProgressIndicator(
semanticsLabel: 'Loading Model Viewer...',
),
);
} else {
return WebView(
backgroundColor: Colors.transparent,
initialUrl: null,
javascriptMode: JavascriptMode.unrestricted,
initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy.always_allow,
Expand Down Expand Up @@ -97,11 +104,6 @@ class ModelViewerState extends State<ModelViewer> {
'>>>> ModelViewer failed to load: ${error.description} (${error.errorType} ${error.errorCode})'); // DEBUG
},
);
} else {
return Center(
child: CircularProgressIndicator(
semanticsLabel: 'Loading Model Viewer...',
));
}
}

Expand All @@ -125,6 +127,11 @@ class ModelViewerState extends State<ModelViewer> {
Future<void> _initProxy() async {
final url = Uri.parse(widget.src);
_proxy = await HttpServer.bind(InternetAddress.loopbackIPv4, 0);

setState(() {
_proxy;
});

_proxy!.listen((final HttpRequest request) async {
//print("${request.method} ${request.uri}"); // DEBUG
//print(request.headers); // DEBUG
Expand Down

0 comments on commit 6b4bb1f

Please sign in to comment.