webview_version 0.0.2 copy "webview_version: ^0.0.2" to clipboard
webview_version: ^0.0.2 copied to clipboard

PlatformAndroid

A flutter plugin to get webview version installed on the device.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:webview_version/webview_version.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _webviewVersion = 'Unknown';
  String? _version = "";
  String? _name = "";

  @override
  void initState() {
    super.initState();
    if(Platform.isAndroid) {
      initWebviewVersion();
    }
  }

  Future<void> initWebviewVersion() async {
    String webviewVersion;
    try {
      _version = await WebviewVersion.getWebviewVersion;
      _name = await WebviewVersion.getWebViewPackage;
      webviewVersion = "$_name:$_version";
    } on PlatformException {
      webviewVersion = 'Failed to get webview version.';
    }
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _webviewVersion = webviewVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: [
              Text('Running on: $_webviewVersion\n'),
              OutlinedButton(
                onPressed: () {
                  final package = _name;
                  if(package != null) {
                    WebviewVersion.startGooglePlay(package);
                  }
                },
                child: Text('Open Google Play'),
              ),
            ],
          )
            ,
        ),
      ),
    );
  }
}
2
likes
150
points
6
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter plugin to get webview version installed on the device.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on webview_version

Packages that implement webview_version