You've already forked flutter-rp-example
39 lines
923 B
Dart
39 lines
923 B
Dart
|
|
import 'dart:io' show Platform;
|
|
|
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
|
|
String getRedirectURI() {
|
|
if (kIsWeb) {
|
|
// Use the current page's origin so the redirect URI always matches
|
|
// the host and port the app is actually served on.
|
|
final base = Uri.base;
|
|
final port = base.hasPort ? ':${base.port}' : '';
|
|
return '/${base.host}$port/auth.html';
|
|
}
|
|
try {
|
|
if (Platform.isAndroid) {
|
|
return "";
|
|
} else {
|
|
return "/localhost:8080/auth.html";
|
|
}
|
|
} catch (e) {
|
|
return "/localhost:8080/auth.html";
|
|
}
|
|
}
|
|
|
|
Future<String> getCallbackUrlScheme() async {
|
|
if (kIsWeb) return "http";
|
|
try {
|
|
if (Platform.isAndroid) {
|
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
|
return packageInfo.packageName;
|
|
} else {
|
|
return "http";
|
|
}
|
|
} catch (e) {
|
|
return "http";
|
|
}
|
|
}
|