diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7ed98a1..e8de460 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,7 +13,7 @@ on: types: [opened, reopened, synchronize] env: - FLUTTER_VERSION: '3.41.7' + FLUTTER_VERSION: 3.x jobs: diff --git a/.github/workflows/installers.yaml b/.github/workflows/installers.yaml index 0a68668..7103178 100644 --- a/.github/workflows/installers.yaml +++ b/.github/workflows/installers.yaml @@ -48,7 +48,7 @@ env: MACOS_APP_RELEASE_UNSIGNED_PATH: build/macos/Build/Products/Release-unsigned MACOS_APP_RELEASE_STAGING_PATH: build/macos/Build/Products/Release-staging MACOS_APP_RELEASE_DEV_PATH: build/macos/Build/Products/Release-dev - FLUTTER_VERSION: "3.41.7" + FLUTTER_VERSION: 3.x jobs: diff --git a/CHANGELOG.md b/CHANGELOG.md index ae84316..64b3aef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ utilised by the flutter version_widget package. ## 0.1 Stable beta release ++ Use file_picker v12.x API [0.0.13] + Remove null/empty values from output JSON [0.0.12 20260511 tonypioneer] + Update file_picker dependency [0.0.11 20260424 anushkavid] + Migrate to universal_web to allow native web build [0.0.10 20260217 dc] diff --git a/analysis_options.yaml b/analysis_options.yaml index 42239ef..3f6e284 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -28,3 +28,4 @@ analyzer: exclude: - ignore/** - ignore/ + - build/** diff --git a/lib/src/widgets/button_file_saver.dart b/lib/src/widgets/button_file_saver.dart index af926d4..44e9a6c 100644 --- a/lib/src/widgets/button_file_saver.dart +++ b/lib/src/widgets/button_file_saver.dart @@ -24,12 +24,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. /// -/// Authors: Tony Chen +/// Authors: Tony Chen, Dawei Chen library; import 'dart:convert'; -import 'dart:io' show File; import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/material.dart'; @@ -129,35 +128,35 @@ Future saveDataForNonWeb( ) async { final messenger = ScaffoldMessenger.of(context); - String? selectedFile = await FilePicker.saveFile( - dialogTitle: 'Please choose a filename and path to save the result', - fileName: defaultFileName, - type: FileType.custom, - allowedExtensions: ['json'], - ); - - if (selectedFile != null) { - final file = File(selectedFile); + try { final jsonContent = jsonEncoder.convert(data); - try { - await file.writeAsString(jsonContent); - debugPrint('File saved at $selectedFile'); + final selectedFileUri = await FilePicker.saveFile( + dialogTitle: 'Please choose a filename and path to save the result', + fileName: defaultFileName, + bytes: utf8.encode(jsonContent), + mimeType: 'application/json', + type: FileType.custom, + allowedExtensions: ['json'], + ); + + if (selectedFileUri != null) { + debugPrint('File saved at $selectedFileUri'); messenger.showSnackBar( - SnackBar(content: Text('Data saved as $selectedFile')), + SnackBar(content: Text('Data saved as $selectedFileUri')), ); - } catch (e) { - debugPrint('Error saving file: $e'); - + } else { + debugPrint('Save file dialog was cancelled.'); messenger.showSnackBar( - SnackBar(content: Text('Error saving file: $e')), + const SnackBar(content: Text('Save cancelled.')), ); } - } else { - debugPrint('Save file dialog was cancelled.'); + } catch (e) { + debugPrint('Error saving file: $e'); + messenger.showSnackBar( - const SnackBar(content: Text('Save cancelled.')), + SnackBar(content: Text('Error saving file: $e')), ); } } diff --git a/pubspec.yaml b/pubspec.yaml index b0ff0ae..3c8b602 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: markdown_widget_builder description: "Widget builder for surveys defined using markdown-like syntax." -version: 0.0.12 +version: 0.0.13 homepage: https://github.com/anusii/markdown_widget_builder environment: @@ -18,15 +18,15 @@ dependencies: flutter: sdk: flutter - audioplayers: ^6.5.1 - file_picker: ^11.0.2 - flutter_markdown_plus: ^1.0.7 + audioplayers: ^6.8.1 + file_picker: ^12.1.3 + flutter_markdown_plus: ^1.0.12 http: ^1.6.0 media_kit: ^1.2.6 media_kit_libs_video: ^1.0.7 media_kit_video: ^2.0.1 path: ^1.9.1 - path_provider: ^2.1.5 + path_provider: ^2.1.6 # universal_html: ^2.3.0 universal_web: ^1.1.1+1 url_launcher: ^6.3.2 @@ -34,7 +34,7 @@ dependencies: dev_dependencies: custom_lint: ^0.8.1 flutter_lints: ^6.0.0 - import_order_lint: ^0.2.2 + import_order_lint: ^0.2.3 flutter: uses-material-design: true