projectName_web.dart.tmpl 950 Bytes
Newer Older
1 2 3 4 5 6 7 8
// In order to *not* need this ignore, consider extracting the "web" version
// of your plugin as a separate package, instead of inlining it in the same
// package as the core of your plugin.
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' as html show window;

import 'package:flutter_web_plugins/flutter_web_plugins.dart';

9
import '{{projectName}}_platform_interface.dart';
10

11 12 13 14
/// A web implementation of the {{pluginDartClass}}Platform of the {{pluginDartClass}} plugin.
class {{pluginDartClass}}Web extends {{pluginDartClass}}Platform {
  /// Constructs a {{pluginDartClass}}Web
  {{pluginDartClass}}Web();
15

16 17
  static void registerWith(Registrar registrar) {
    {{pluginDartClass}}Platform.instance = {{pluginDartClass}}Web();
18 19 20
  }

  /// Returns a [String] containing the version of the platform.
21 22
  @override
  Future<String?> getPlatformVersion() async {
23
    final version = html.window.navigator.userAgent;
24
    return version;
25 26
  }
}