Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Msix.assetUri() to get an ms-appx:/// URI of Flutter assets #293

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.17.0

- Add `Msix.assetUri()` to get an `ms-appx:///` URI out of any Flutter asset name.

## 3.16.8

- update VCLibs files [#273](https://github.com/YehudaKremer/msix/pull/273)
Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ it on a website.

## 📋 Installation

In your `pubspec.yaml`, add the `msix` package as a new [dev dependency] with
In your `pubspec.yaml`, add the `msix` package as a new dependency with
the following command:

```console
PS c:\src\flutter_project> flutter pub add --dev msix
PS c:\src\flutter_project> dart pub add msix
```

## 📦 Creating an MSIX installer
Expand Down Expand Up @@ -135,6 +135,21 @@ the `certificate_path` and `certificate_password` fields.
machine. You can disable this by using the `--install-certificate false` option, or the YAML
option `install_certificate: false`.

## Using Assets

If you need to get an `ms-appx:///` URI from a Flutter asset, use `Msix.assetUrI()`:

```dart
// Flutter
final logoPath = 'assets/logo.png';
Image.asset(logoPath);

// Windows APIs
final logoUri = Msix.assetUri('assets/logo.png');
someWindowsApi(logoUri);
```


## ![microsoft store icon][] Publishing to the Microsoft Store

To generate an MSIX file for publishing to the Microsoft Store, use the
Expand Down
2 changes: 2 additions & 0 deletions lib/msix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import 'src/method_extensions.dart';

/// Main class that handles all the msix package functionality
class Msix {
static Uri assetUri(String path) => Uri.parse("ms-appx:///data/flutter_assets/$path");

late Logger _logger;
late Configuration _config;

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: msix
description: A command-line tool that create Msix installer from your flutter windows-build files.
version: 3.16.8
version: 3.17.0
maintainer: Yehuda Kremer ([email protected])
homepage: https://github.com/YehudaKremer/msix
issue_tracker: https://github.com/YehudaKremer/msix/issues
Expand Down
10 changes: 10 additions & 0 deletions test/misc_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:msix/msix.dart';
import 'package:test/test.dart';

void main() => test(
'Asset URIs are valid',
() => expect(
Msix.assetUri('assets/image.jpg'),
Uri.parse('ms-appx:///data/flutter_assets/assets/image.jpg'),
),
);