mirror of
https://github.com/kphanipavan/modal_progress_hud_nsn.git
synced 2025-10-28 22:32:50 -07:00
Added dart support code
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
library modal_progress_hud;
|
||||
library modal_progress_hud_nsn;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:ui';
|
||||
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
|
||||
@@ -32,7 +39,7 @@ class ModalProgressHUD extends StatelessWidget {
|
||||
/// A [Widget] which should be the the widget to be shown behind the loading barrier.
|
||||
final Widget child;
|
||||
|
||||
/// A [double] value specifying the amount of background blur of the progress.
|
||||
/// A [double] value specifying the amount of background blur when progress hud is active.
|
||||
final double blur;
|
||||
|
||||
const ModalProgressHUD({
|
||||
@@ -56,9 +63,9 @@ class ModalProgressHUD extends StatelessWidget {
|
||||
layOutProgressIndicator = Center(child: progressIndicator);
|
||||
} else {
|
||||
layOutProgressIndicator = Positioned(
|
||||
child: progressIndicator,
|
||||
left: offset!.dx,
|
||||
top: offset!.dy,
|
||||
child: progressIndicator,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -68,8 +75,8 @@ class ModalProgressHUD extends StatelessWidget {
|
||||
BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: blur, sigmaY: blur),
|
||||
child: Opacity(
|
||||
child: ModalBarrier(dismissible: dismissible, color: color),
|
||||
opacity: opacity,
|
||||
child: ModalBarrier(dismissible: dismissible, color: color),
|
||||
),
|
||||
),
|
||||
layOutProgressIndicator,
|
||||
|
||||
17
lib/modal_progress_hud_nsn_method_channel.dart
Normal file
17
lib/modal_progress_hud_nsn_method_channel.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
29
lib/modal_progress_hud_nsn_platform_interface.dart
Normal file
29
lib/modal_progress_hud_nsn_platform_interface.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
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.');
|
||||
}
|
||||
}
|
||||
26
lib/modal_progress_hud_nsn_web.dart
Normal file
26
lib/modal_progress_hud_nsn_web.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user