mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-17 04:35:26 +00:00
Add function to open a link
- Does not seem to actually ... work.. yet
This commit is contained in:
@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:InvenTree/api.dart';
|
||||
import 'package:InvenTree/widget/dialogs.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
@ -54,6 +55,19 @@ class InvenTreeModel {
|
||||
// Legacy API provided external link as "URL", while newer API uses "link"
|
||||
String get link => jsondata['link'] ?? jsondata['URL'] ?? '';
|
||||
|
||||
void openLink() async {
|
||||
|
||||
if (link.isNotEmpty) {
|
||||
print("Opening link: ${link}");
|
||||
|
||||
if (await canLaunch(link)) {
|
||||
await launch(url);
|
||||
} else {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String get keywords => jsondata['keywords'] as String ?? '';
|
||||
|
||||
// Create a new object from JSON data (not a constructor!)
|
||||
|
Reference in New Issue
Block a user