Flutter Desktop Apps: Getting Started

Mar 28 2023 · Dart 2.19, Flutter 3.7, Android Studio 2021.3.1 or higher, Visual Studo Code 1.7.4 or higher

Part 1: Flutter Desktop Apps

10. Exporting Data

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 09. Macintosh Entitlements Next episode: 11. Importing Data

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 10. Exporting Data

See https://pub.dev/packages/filesystem_picker.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Android Studio

Open up pubspec.yaml add add the following plugin:

file_picker: ^5.2.5
final path = await FilePicker.platform.getDirectoryPath();
// 1
if (path != null) {
  // 2
  final file = File('$path/exports.todo');
  // 3
  if (await file.exists()) {
    await file.delete();
  }
  // 4
  final repository = ref.read(repositoryProvider);
  final todoController = ref.read(todoControllerProvider);
  final todoLists = todoController.todoList;

  final jsonList = <TodoList>[];
  await Future.forEach(todoLists, (list) async {
    jsonList.add(await repository.fillTodoList(list));
  });
  await file.writeAsString(jsonEncode(jsonList));
}

Finder

On the Mac, open up the file and you can see the json the export command created.