Skip to content

Commit f048964

Browse files
committed
add use-asset-paths arg
1 parent da469d0 commit f048964

File tree

4 files changed

+27
-24
lines changed

4 files changed

+27
-24
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ API access is available only to users with active subscriptions. Visit https://a
1414

1515
### Usage
1616

17-
`flutterflow export-code --project <project id> --dest <output folder> --[no-]include-assets --token <token> --[no-]fix --[no-]parent-folder --[no-]as-module --[no-]as-debug`
17+
`flutterflow export-code --project <project id> --dest <output folder> --[no-]include-assets --token <token> --[no-]fix --[no-]parent-folder --[no-]as-module --[no-]as-debug --[no-]use-package-asset-paths`
1818

1919
* Instead of passing `--token` you can set `FLUTTERFLOW_API_TOKEN` environment variable.
2020
* Instead of passing `--project` you can set `FLUTTERFLOW_PROJECT` environment variable.
@@ -35,6 +35,7 @@ with a list of files to be ignored using [globbing syntax](https://pub.dev/packa
3535
| `--[no-]parent-folder` | None | [Optional] Whether to download code into a project-named sub-folder. If true, downloads all project files directly to the specified directory. Defaults to `true`. |
3636
| `--[no-]as-module` | None | [Optional] Whether to generate the project as a Flutter module. Defaults to `false`. |
3737
| `--[no-]as-debug` | None | [Optional] Whether to generate the project with debug logging to be able to use FlutterFlow Debug Panel inside the DevTools. Defaults to `false`. |
38+
| `--[no-]use-package-asset-paths` | None | [Optional] Whether to use package asset paths in the generated code. If enabled, all asset paths will be prepended with 'package/$projectName', making them correctly referenceable when importing this Flutter project as a package. Defaults to `false`. |
3839
| `--project-environment` | None | [Optional] Which project environment to be used. If empty, the current environment in the project will be used.|
3940
## Deploy Firebase
4041

bin/flutterflow_cli.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ Future<void> appMain(List<String> args) async {
5858
fix: parsedArguments.command!['fix'],
5959
exportAsModule: parsedArguments.command!['as-module'],
6060
exportAsDebug: parsedArguments.command!['as-debug'],
61+
usePackageAssetPaths:
62+
parsedArguments.command!['use-package-asset-paths'],
6163
environmentName: parsedArguments.command!['project-environment'],
6264
);
6365
break;
@@ -133,6 +135,12 @@ ArgResults _parseArgs(List<String> args) {
133135
'FlutterFlow Debug Panel inside the DevTools.',
134136
defaultsTo: false,
135137
)
138+
..addFlag(
139+
'use-package-asset-paths',
140+
negatable: true,
141+
help: 'Use package asset paths in the generated code.',
142+
defaultsTo: false,
143+
)
136144
..addOption(
137145
'project-environment',
138146
help: '(Optional) Specify a project environment name.',

lib/src/flutterflow_api_client.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class FlutterFlowApi {
2929
/// * [exportAsDebug] flag indicates whether to export the code as debug for
3030
/// local run.
3131
/// * [environmentName] is the name of the environment to export the code for.
32+
/// * [usePackageAssetPaths] flag indicates whether to use package asset paths.
3233
///
3334
/// Returns a [Future] that completes with the path to the exported code, or
3435
/// throws an error if the export fails.
@@ -46,6 +47,7 @@ class FlutterFlowApi {
4647
bool exportAsModule = false,
4748
bool format = true,
4849
bool exportAsDebug = false,
50+
bool usePackageAssetPaths = false,
4951
}) =>
5052
exportCode(
5153
token: token,
@@ -60,6 +62,7 @@ class FlutterFlowApi {
6062
exportAsModule: exportAsModule,
6163
format: format,
6264
exportAsDebug: exportAsDebug,
65+
usePackageAssetPaths: usePackageAssetPaths,
6366
);
6467
}
6568

@@ -77,6 +80,7 @@ Future<String?> exportCode({
7780
String? environmentName,
7881
String? commitHash,
7982
bool exportAsDebug = false,
83+
bool usePackageAssetPaths = false,
8084
}) async {
8185
stderr.write('Downloading code with the FlutterFlow CLI...\n');
8286
stderr.write('You are exporting project $projectId.\n');
@@ -101,6 +105,7 @@ Future<String?> exportCode({
101105
includeAssets: includeAssets,
102106
format: format,
103107
exportAsDebug: exportAsDebug,
108+
usePackageAssetPaths: usePackageAssetPaths,
104109
);
105110
// Download actual code
106111
final projectZipBytes = base64Decode(result['project_zip']);
@@ -177,6 +182,7 @@ Future<dynamic> _callExport({
177182
required bool includeAssets,
178183
required bool format,
179184
required bool exportAsDebug,
185+
required bool usePackageAssetPaths,
180186
}) async {
181187
final body = jsonEncode({
182188
'project': {'path': 'projects/$projectId'},
@@ -187,6 +193,7 @@ Future<dynamic> _callExport({
187193
'include_assets_map': includeAssets,
188194
'format': format,
189195
'export_as_debug': exportAsDebug,
196+
'use_package_asset_paths': usePackageAssetPaths,
190197
});
191198
return await _callEndpoint(
192199
client: client,

pubspec.lock

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,18 @@ packages:
55
dependency: transitive
66
description:
77
name: _fe_analyzer_shared
8-
sha256: "45cfa8471b89fb6643fe9bf51bd7931a76b8f5ec2d65de4fb176dba8d4f22c77"
8+
sha256: dc27559385e905ad30838356c5f5d574014ba39872d732111cd07ac0beff4c57
99
url: "https://pub.dev"
1010
source: hosted
11-
version: "73.0.0"
12-
_macros:
13-
dependency: transitive
14-
description: dart
15-
source: sdk
16-
version: "0.3.2"
11+
version: "80.0.0"
1712
analyzer:
1813
dependency: transitive
1914
description:
2015
name: analyzer
21-
sha256: "4959fec185fe70cce007c57e9ab6983101dbe593d2bf8bbfb4453aaec0cf470a"
16+
sha256: "192d1c5b944e7e53b24b5586db760db934b177d4147c42fbca8c8c5f1eb8d11e"
2217
url: "https://pub.dev"
2318
source: hosted
24-
version: "6.8.0"
19+
version: "7.3.0"
2520
archive:
2621
dependency: "direct main"
2722
description:
@@ -42,10 +37,10 @@ packages:
4237
dependency: transitive
4338
description:
4439
name: async
45-
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
40+
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
4641
url: "https://pub.dev"
4742
source: hosted
48-
version: "2.12.0"
43+
version: "2.13.0"
4944
boolean_selector:
5045
dependency: transitive
5146
description:
@@ -174,14 +169,6 @@ packages:
174169
url: "https://pub.dev"
175170
source: hosted
176171
version: "1.3.0"
177-
macros:
178-
dependency: transitive
179-
description:
180-
name: macros
181-
sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536"
182-
url: "https://pub.dev"
183-
source: hosted
184-
version: "0.1.2-main.4"
185172
matcher:
186173
dependency: transitive
187174
description:
@@ -282,10 +269,10 @@ packages:
282269
dependency: transitive
283270
description:
284271
name: shelf_web_socket
285-
sha256: cc36c297b52866d203dbf9332263c94becc2fe0ceaa9681d07b6ef9807023b67
272+
sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925"
286273
url: "https://pub.dev"
287274
source: hosted
288-
version: "2.0.1"
275+
version: "3.0.0"
289276
source_map_stack_trace:
290277
dependency: transitive
291278
description:
@@ -346,10 +333,10 @@ packages:
346333
dependency: "direct dev"
347334
description:
348335
name: test
349-
sha256: "8391fbe68d520daf2314121764d38e37f934c02fd7301ad18307bd93bd6b725d"
336+
sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e"
350337
url: "https://pub.dev"
351338
source: hosted
352-
version: "1.25.14"
339+
version: "1.25.15"
353340
test_api:
354341
dependency: transitive
355342
description:

0 commit comments

Comments
 (0)