Skip to content

Commit

Permalink
Fix Web implementation not being found properly
Browse files Browse the repository at this point in the history
Fix #82
  • Loading branch information
ThexXTURBOXx committed Oct 27, 2023
1 parent bd024f0 commit 31d59ac
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 85 deletions.
5 changes: 3 additions & 2 deletions flutter_web_auth_2/lib/flutter_web_auth_2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_web_auth_2/src/options.dart';
import 'package:flutter_web_auth_2_platform_interface/flutter_web_auth_2_platform_interface.dart';

export 'src/linux.dart';
export 'src/options.dart';
export 'src/windows.dart' if (dart.library.html) 'src/web.dart';
export 'src/unsupported.dart'
if (dart.library.io) 'src/server.dart'
if (dart.library.html) 'src/web.dart';

class _OnAppLifecycleResumeObserver extends WidgetsBindingObserver {
final Function onResumed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import 'package:flutter_web_auth_2_platform_interface/flutter_web_auth_2_platfor
import 'package:url_launcher/url_launcher.dart';
import 'package:window_to_front/window_to_front.dart';

/// Implements the plugin interface for Windows.
class FlutterWebAuth2LinuxPlugin extends FlutterWebAuth2Platform {
/// Implements the plugin interface using an internal server (currently used by
/// Windows and Linux).
class FlutterWebAuth2ServerPlugin extends FlutterWebAuth2Platform {
HttpServer? _server;
Timer? _authTimeout;

/// Registers the Windows implementation.
/// Registers the internal server implementation.
static void registerWith() {
FlutterWebAuth2Platform.instance = FlutterWebAuth2LinuxPlugin();
FlutterWebAuth2Platform.instance = FlutterWebAuth2ServerPlugin();
}

@override
Expand Down
31 changes: 31 additions & 0 deletions flutter_web_auth_2/lib/src/unsupported.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter/services.dart';
import 'package:flutter_web_auth_2_platform_interface/flutter_web_auth_2_platform_interface.dart';

/// Implements the plugin interface for unsupported platforms (just throws
/// errors).
class FlutterWebAuth2UnsupportedPlugin extends FlutterWebAuth2Platform {
/// Registers the unsupported implementation.
static void registerWith() {
FlutterWebAuth2Platform.instance = FlutterWebAuth2UnsupportedPlugin();
}

@override
Future<String> authenticate({
required String url,
required String callbackUrlScheme,
required Map<String, dynamic> options,
}) async {
throw PlatformException(
message: 'Platform either unsupported or unrecognised.',
code: 'UNSUPPORTED',
);
}

@override
Future clearAllDanglingCalls() async {
throw PlatformException(
message: 'Platform either unsupported or unrecognised.',
code: 'UNSUPPORTED',
);
}
}
75 changes: 0 additions & 75 deletions flutter_web_auth_2/lib/src/windows.dart

This file was deleted.

8 changes: 4 additions & 4 deletions flutter_web_auth_2/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ flutter:
ios:
pluginClass: FlutterWebAuth2Plugin
linux:
dartPluginClass: FlutterWebAuth2LinuxPlugin
fileName: src/linux.dart
dartPluginClass: FlutterWebAuth2ServerPlugin
fileName: src/server.dart
macos:
pluginClass: FlutterWebAuth2Plugin
web:
pluginClass: FlutterWebAuth2WebPlugin
fileName: src/web.dart
windows:
dartPluginClass: FlutterWebAuth2WindowsPlugin
fileName: src/windows.dart
dartPluginClass: FlutterWebAuth2ServerPlugin
fileName: src/server.dart

0 comments on commit 31d59ac

Please sign in to comment.