Skip to content

Commit e80f010

Browse files
Merge pull request #15 from FlutterFlow/wenkai/export_as_module
add the as-module option
2 parents 082548c + 9b98caf commit e80f010

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.0.13
2+
3+
- Add `--as-module` option.
4+
15
## 0.0.12
26

37
- Fix `FLUTTERFLOW_PROJECT` environment variable issue.

README.md

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

1313
## Usage
1414

15-
`flutterflow export-code --project <project id> --dest <output folder> --[no-]include-assets --token <token> --[no-]fix --[no]-parent-folder`
15+
`flutterflow export-code --project <project id> --dest <output folder> --[no-]include-assets --token <token> --[no-]fix --[no-]parent-folder --[no-]as-module`
1616

1717
* Instead of passing `--token` you can set `FLUTTERFLOW_API_TOKEN` environment variable.
1818
* Instead of passing `--project` you can set `FLUTTERFLOW_PROJECT` environment variable.
@@ -28,6 +28,7 @@ API access is available only to users with active subscriptions. Visit https://a
2828
| `--branch-name` | `-b` | [Optional] Which branch to download. Defaults to `main`. |
2929
| `--[no-]fix` | None | [Optional] Whether to run `dart fix` on the downloaded code. Defaults to `false`. |
3030
| `--[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`. |
31+
| `--[no-]as-module` | None | [Optional] Whether to generate the project as a Flutter module |
3132

3233
## Issues
3334

bin/flutterflow_cli.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ void main(List<String> args) async {
5252
branchName: parsedArguments.command!['branch-name'],
5353
unzipToParentFolder: parsedArguments.command!['parent-folder'],
5454
fix: parsedArguments.command!['fix'],
55+
exportAsModule: parsedArguments.command!['as-module'],
5556
);
5657
}
5758

@@ -85,6 +86,12 @@ ArgResults _parseArgs(List<String> args) {
8586
'download all project code directly into the specified directory, '
8687
'or the current directory if --dest is not set.',
8788
defaultsTo: true,
89+
)
90+
..addFlag(
91+
'as-module',
92+
negatable: true,
93+
help: 'Generate the project as a Flutter module.',
94+
defaultsTo: false,
8895
);
8996

9097
final parser = ArgParser()

lib/src/flutterflow_cli_base.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class FlutterFlowApi {
3434
String? branchName,
3535
bool unzipToParentFolder = false,
3636
bool fix = false,
37+
bool exportAsModule = false,
3738
}) =>
3839
exportCode(
3940
token: token,
@@ -44,6 +45,7 @@ class FlutterFlowApi {
4445
branchName: branchName,
4546
unzipToParentFolder: unzipToParentFolder,
4647
fix: fix,
48+
exportAsModule: exportAsModule,
4749
);
4850
}
4951

@@ -55,6 +57,7 @@ Future<String?> exportCode({
5557
required bool includeAssets,
5658
required bool unzipToParentFolder,
5759
required bool fix,
60+
required bool exportAsModule,
5861
String? branchName,
5962
}) async {
6063
final endpointUrl = Uri.parse(endpoint);
@@ -67,6 +70,7 @@ Future<String?> exportCode({
6770
endpoint: endpointUrl,
6871
projectId: projectId,
6972
branchName: branchName,
73+
exportAsModule: exportAsModule,
7074
);
7175
// Download actual code
7276
final projectZipBytes = base64Decode(result['project_zip']);
@@ -136,13 +140,15 @@ Future<dynamic> _callExport({
136140
required Uri endpoint,
137141
required String projectId,
138142
String? branchName,
143+
required bool exportAsModule,
139144
}) async {
140145
final body = jsonEncode({
141146
'project': {
142147
'path': 'projects/$projectId',
143148
},
144149
'token': token,
145150
if (branchName != null) 'branch_name': branchName,
151+
'export_as_module': exportAsModule,
146152
});
147153
final response = await client.post(
148154
Uri.https(endpoint.host, '${endpoint.path}/exportCode'),

0 commit comments

Comments
 (0)