port plugin to package

This commit is contained in:
Phani Pavan K
2024-01-21 12:20:46 +05:30
parent a29f39fcfb
commit f963256834
75 changed files with 653 additions and 1243 deletions

View File

@@ -1,15 +1,8 @@
library modal_progress_hud_nsn;
import "modal_progress_hud_nsn_platform_interface.dart";
import "package:flutter/material.dart";
import "dart:ui";
class ModalProgressHudNsn {
Future<String?> getPlatformVersion() {
return ModalProgressHudNsnPlatform.instance.getPlatformVersion();
}
}
///
/// Wrap around any widget that makes an async call to show a modal progress
/// indicator while the async call is in progress.

View File

@@ -1,18 +0,0 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'modal_progress_hud_nsn_platform_interface.dart';
/// An implementation of [ModalProgressHudNsnPlatform] that uses method channels.
class MethodChannelModalProgressHudNsn extends ModalProgressHudNsnPlatform {
/// The method channel used to interact with the native platform.
@visibleForTesting
final methodChannel = const MethodChannel('modal_progress_hud_nsn');
@override
Future<String?> getPlatformVersion() async {
final version =
await methodChannel.invokeMethod<String>('getPlatformVersion');
return version;
}
}

View File

@@ -1,30 +0,0 @@
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'modal_progress_hud_nsn_method_channel.dart';
abstract class ModalProgressHudNsnPlatform extends PlatformInterface {
/// Constructs a ModalProgressHudNsnPlatform.
ModalProgressHudNsnPlatform() : super(token: _token);
static final Object _token = Object();
static ModalProgressHudNsnPlatform _instance =
MethodChannelModalProgressHudNsn();
/// The default instance of [ModalProgressHudNsnPlatform] to use.
///
/// Defaults to [MethodChannelModalProgressHudNsn].
static ModalProgressHudNsnPlatform get instance => _instance;
/// Platform-specific implementations should set this with their own
/// platform-specific class that extends [ModalProgressHudNsnPlatform] when
/// they register themselves.
static set instance(ModalProgressHudNsnPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
_instance = instance;
}
Future<String?> getPlatformVersion() {
throw UnimplementedError('platformVersion() has not been implemented.');
}
}

View File

@@ -1,26 +0,0 @@
// 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';
import 'modal_progress_hud_nsn_platform_interface.dart';
/// A web implementation of the ModalProgressHudNsnPlatform of the ModalProgressHudNsn plugin.
class ModalProgressHudNsnWeb extends ModalProgressHudNsnPlatform {
/// Constructs a ModalProgressHudNsnWeb
ModalProgressHudNsnWeb();
static void registerWith(Registrar registrar) {
ModalProgressHudNsnPlatform.instance = ModalProgressHudNsnWeb();
}
/// Returns a [String] containing the version of the platform.
@override
Future<String?> getPlatformVersion() async {
final version = html.window.navigator.userAgent;
return version;
}
}