Skip to content

Commit

Permalink
Remove file saver.
Browse files Browse the repository at this point in the history
  • Loading branch information
bosskmk committed Jun 11, 2022
1 parent b4a9e78 commit 0f65b55
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 28 deletions.
13 changes: 0 additions & 13 deletions demo/lib/screen/development_screen.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import 'dart:convert';

import 'package:file_saver/file_saver.dart';
import 'package:flutter/material.dart';
import 'package:pluto_grid/pluto_grid.dart';
import 'package:pluto_grid_export/pluto_grid_export.dart' as pluto_grid_export;

import '../dummy_data/development.dart';
import 'empty_screen.dart';
Expand Down Expand Up @@ -230,13 +226,6 @@ class _HeaderState extends State<_Header> {
.setShowColumnFilter(!widget.stateManager.showColumnFilter);
}

void handleExport() async {
String title = "pluto_grid_export";
var exported = const Utf8Encoder().convert(
pluto_grid_export.PlutoGridExport.exportCSV(widget.stateManager));
await FileSaver.instance.saveFile("$title.csv", exported, ".csv");
}

void setGridSelectingMode(PlutoGridSelectingMode? mode) {
if (gridSelectingMode == mode || mode == null) {
return;
Expand Down Expand Up @@ -296,8 +285,6 @@ class _HeaderState extends State<_Header> {
onPressed: handleRemoveSelectedRowsButton,
child: const Text('Remove Selected Rows'),
),
ElevatedButton(
onPressed: handleExport, child: const Text("Export to CSV")),
DropdownButtonHideUnderline(
child: DropdownButton(
value: gridSelectingMode,
Expand Down
17 changes: 11 additions & 6 deletions demo/lib/screen/feature/export_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ignore_for_file: unused_local_variable

import 'dart:convert';

import 'package:file_saver/file_saver.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:pluto_grid/pluto_grid.dart';
Expand Down Expand Up @@ -134,7 +135,11 @@ class _ExportScreenState extends State<ExportScreen> {
title: 'Export / download as PDF or CSV',
topTitle: 'Export / download as PDF or CSV',
topContents: const [
Text('You can export grid contents as PDF or CSV'),
Text(
'You can export grid contents as PDF or CSV with pluto_grid_export package from pub.dev.'),
Text("The example doesn't actually download the file."),
Text(
'The file download part is implemented directly for each platform or is possible through a package such as FileSaver.'),
],
topButtons: [
PlutoExampleButton(
Expand Down Expand Up @@ -219,7 +224,7 @@ class _HeaderState extends State<_Header> {
String title = "pluto_grid_export";
var exported = const Utf8Encoder().convert(
pluto_grid_export.PlutoGridExport.exportCSV(widget.stateManager));
await FileSaver.instance.saveFile("$title.csv", exported, ".csv");
// await FileSaver.instance.saveFile("$title.csv", exported, ".csv");
}

void _defaultExportGridAsCSVCompatibleWithExcel() async {
Expand All @@ -231,7 +236,7 @@ class _HeaderState extends State<_Header> {
// This allows open the file in Excel with proper character interpretation
// See https://stackoverflow.com/a/155176
'\u{FEFF}$exportCSV');
await FileSaver.instance.saveFile("$title.csv", exported, ".csv");
// await FileSaver.instance.saveFile("$title.csv", exported, ".csv");
}

void _defaultExportGridAsCSVFakeExcel() async {
Expand All @@ -243,7 +248,7 @@ class _HeaderState extends State<_Header> {
// This allows open the file in Excel with proper character interpretation
// See https://stackoverflow.com/a/155176
'\u{FEFF}$exportCSV');
await FileSaver.instance.saveFile("$title.xls", exported, ".xls");
// await FileSaver.instance.saveFile("$title.xls", exported, ".xls");
}

// void _exportGridAsTSV() async {
Expand All @@ -262,7 +267,7 @@ class _HeaderState extends State<_Header> {
widget.stateManager,
fieldDelimiter: ";",
));
await FileSaver.instance.saveFile("$title.csv", exported, ".csv");
// await FileSaver.instance.saveFile("$title.csv", exported, ".csv");
}

@override
Expand Down
4 changes: 0 additions & 4 deletions demo/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@
import FlutterMacOS
import Foundation

import file_saver
import path_provider_macos
import printing
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FileSaverPlugin.register(with: registry.registrar(forPlugin: "FileSaverPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
PrintingPlugin.register(with: registry.registrar(forPlugin: "PrintingPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
1 change: 0 additions & 1 deletion demo/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ dependencies:
url_launcher: ^6.1.2
font_awesome_flutter: ^10.1.0
rainbow_color: ^2.0.1
file_saver: ^0.1.0


# The following adds the Cupertino Icons font to your application.
Expand Down
3 changes: 0 additions & 3 deletions demo/windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@

#include "generated_plugin_registrant.h"

#include <file_saver/file_saver_plugin.h>
#include <printing/printing_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
FileSaverPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSaverPlugin"));
PrintingPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PrintingPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
Expand Down
1 change: 0 additions & 1 deletion demo/windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
file_saver
printing
url_launcher_windows
)
Expand Down

0 comments on commit 0f65b55

Please sign in to comment.