Skip to content
Prev Previous commit
Next Next commit
enum -> class
  • Loading branch information
goderbauer committed Jan 3, 2024
commit cd41e349557f176053dff4d56067dc721b0f0381
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,35 @@ const MethodCodec _codec = JSONMethodCodec();
///
/// This is a class instead of an enum to allow future customizability e.g.
/// opening a link in a specific iframe.
enum LinkTarget {
class LinkTarget { // ignore: use_enums
/// Const private constructor with a [debugLabel] to allow the creation of
/// multiple distinct const instances.
const LinkTarget._({required this.debugLabel});

/// Used to distinguish multiple const instances of [LinkTarget].
final String debugLabel;

/// Use the default target for each platform.
///
/// On Android, the default is [blank]. On the web, the default is [self].
///
/// iOS, on the other hand, defaults to [self] for web URLs, and [blank] for
/// non-web URLs.
defaultTarget._(debugLabel: 'defaultTarget'),
static const LinkTarget defaultTarget =
LinkTarget._(debugLabel: 'defaultTarget');

/// On the web, this opens the link in the same tab where the flutter app is
/// running.
///
/// On Android and iOS, this opens the link in a webview within the app.
self._(debugLabel: 'self'),
static const LinkTarget self = LinkTarget._(debugLabel: 'self');

/// On the web, this opens the link in a new tab or window (depending on the
/// browser and user configuration).
///
/// On Android and iOS, this opens the link in the browser or the relevant
/// app.
blank._(debugLabel: 'blank');

/// Const private constructor with a [debugLabel] to allow the creation of
/// multiple distinct const instances.
const LinkTarget._({required this.debugLabel});

/// Used to distinguish multiple const instances of [LinkTarget].
final String debugLabel;
static const LinkTarget blank = LinkTarget._(debugLabel: 'blank');
}

/// Encapsulates all the information necessary to build a Link widget.
Expand Down
2 changes: 1 addition & 1 deletion packages/url_launcher/url_launcher_web/lib/src/link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class LinkViewController extends PlatformViewController {
// with a version that contains new values. This is deliberately outside
// the switch rather than a `default` so that the linter will flag the
// switch as needing an update.
return '_self'; // ignore: dead_code
return '_self';
}

@override
Expand Down