Verificamos profundamente cada una de las secciones de nuestro espacio con el objetivo de mostrarte en todo momento la información más veraz y certera.
Ejemplo: comprobar la conectividad flutter para webview
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:connectivity/connectivity.dart';
void main() => runApp(MyApp());
var connectivityResult = await (Connectivity().checkConnectivity());
await(Future<ConnectivityResult> checkConnectivity)
class MyApp extends StatelessWidget
@override
Widget build(BuildContext context)
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.yellow
),
home: MyHomePage(title: 'Flutter Demooo Home Page'),
);
class MyHomePage extends StatefulWidget
MyHomePage(Key key, this.title) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
class _MyHomePageState extends State<MyHomePage>
final Completer<WebViewController> _controller=Completer<WebViewController>();
@override
Widget build(BuildContext context)
return Scaffold(
body: WebView(
if (connectivityResult == ConnectivityResult.mobile)
// I am connected to a mobile network.
else if (connectivityResult == ConnectivityResult.wifi)
// I am connected to a wifi network.
initialUrl: "https://google.com/",
onWebViewCreated: (WebViewController webViewController)
_controller.complete(webViewController);
,
else
//i am not connected to any network
) );
Si crees que ha resultado de ayuda nuestro post, sería de mucha ayuda si lo compartieras con más programadores de esta manera nos ayudas a extender este contenido.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)