Skip to content

Commit

Permalink
Compatible with Flutter 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
bosskmk committed May 10, 2023
1 parent 58dbb03 commit 6d1e224
Show file tree
Hide file tree
Showing 17 changed files with 133 additions and 116 deletions.
6 changes: 3 additions & 3 deletions demo/lib/screen/development_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,12 @@ class _NoRows extends StatelessWidget {
border: Border.all(),
borderRadius: const BorderRadius.all(Radius.circular(5)),
),
child: Padding(
padding: const EdgeInsets.all(10),
child: const Padding(
padding: EdgeInsets.all(10),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: const [
children: [
Icon(Icons.info_outline),
SizedBox(height: 5),
Text('There are no records'),
Expand Down
94 changes: 46 additions & 48 deletions demo/lib/screen/feature/export_screen.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// ignore_for_file: unused_local_variable

import 'dart:convert';

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

// import 'package:pluto_grid_export/pluto_grid_export.dart' as pluto_grid_export;

import '../../dummy_data/development.dart';
import '../../widget/pluto_example_button.dart';
Expand Down Expand Up @@ -179,25 +177,25 @@ class _Header extends StatefulWidget {

class _HeaderState extends State<_Header> {
void _printToPdfAndShareOrSave() async {
final themeData = pluto_grid_export.ThemeData.withFont(
base: pluto_grid_export.Font.ttf(
await rootBundle.load('assets/fonts/open_sans/OpenSans-Regular.ttf'),
),
bold: pluto_grid_export.Font.ttf(
await rootBundle.load('assets/fonts/open_sans/OpenSans-Bold.ttf'),
),
);

var plutoGridPdfExport = pluto_grid_export.PlutoGridDefaultPdfExport(
title: "Pluto Grid Sample pdf print",
creator: "Pluto Grid Rocks!",
format: pluto_grid_export.PdfPageFormat.a4.landscape,
themeData: themeData,
);

await pluto_grid_export.Printing.sharePdf(
bytes: await plutoGridPdfExport.export(widget.stateManager),
filename: plutoGridPdfExport.getFilename());
// final themeData = pluto_grid_export.ThemeData.withFont(
// base: pluto_grid_export.Font.ttf(
// await rootBundle.load('assets/fonts/open_sans/OpenSans-Regular.ttf'),
// ),
// bold: pluto_grid_export.Font.ttf(
// await rootBundle.load('assets/fonts/open_sans/OpenSans-Bold.ttf'),
// ),
// );
//
// var plutoGridPdfExport = pluto_grid_export.PlutoGridDefaultPdfExport(
// title: "Pluto Grid Sample pdf print",
// creator: "Pluto Grid Rocks!",
// format: pluto_grid_export.PdfPageFormat.a4.landscape,
// themeData: themeData,
// );
//
// await pluto_grid_export.Printing.sharePdf(
// bytes: await plutoGridPdfExport.export(widget.stateManager),
// filename: plutoGridPdfExport.getFilename());
}

// This doesn't works properly in systems different from Windows.
Expand All @@ -221,33 +219,33 @@ class _HeaderState extends State<_Header> {
// }

void _defaultExportGridAsCSV() async {
String title = "pluto_grid_export";
var exported = const Utf8Encoder().convert(
pluto_grid_export.PlutoGridExport.exportCSV(widget.stateManager));
// 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 _defaultExportGridAsCSVCompatibleWithExcel() async {
String title = "pluto_grid_export";
var exportCSV =
pluto_grid_export.PlutoGridExport.exportCSV(widget.stateManager);
var exported = const Utf8Encoder().convert(
// FIX Add starting \u{FEFF} / 0xEF, 0xBB, 0xBF
// This allows open the file in Excel with proper character interpretation
// See https://stackoverflow.com/a/155176
'\u{FEFF}$exportCSV');
// String title = "pluto_grid_export";
// var exportCSV =
// pluto_grid_export.PlutoGridExport.exportCSV(widget.stateManager);
// var exported = const Utf8Encoder().convert(
// // FIX Add starting \u{FEFF} / 0xEF, 0xBB, 0xBF
// // 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");
}

void _defaultExportGridAsCSVFakeExcel() async {
String title = "pluto_grid_export";
var exportCSV =
pluto_grid_export.PlutoGridExport.exportCSV(widget.stateManager);
var exported = const Utf8Encoder().convert(
// FIX Add starting \u{FEFF} / 0xEF, 0xBB, 0xBF
// This allows open the file in Excel with proper character interpretation
// See https://stackoverflow.com/a/155176
'\u{FEFF}$exportCSV');
// String title = "pluto_grid_export";
// var exportCSV =
// pluto_grid_export.PlutoGridExport.exportCSV(widget.stateManager);
// var exported = const Utf8Encoder().convert(
// // FIX Add starting \u{FEFF} / 0xEF, 0xBB, 0xBF
// // 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");
}

Expand All @@ -261,12 +259,12 @@ class _HeaderState extends State<_Header> {
// }

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

Expand Down
1 change: 0 additions & 1 deletion demo/linux/flutter/ephemeral/.plugin_symlinks/printing

This file was deleted.

4 changes: 0 additions & 4 deletions demo/linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

#include "generated_plugin_registrant.h"

#include <printing/printing_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) printing_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "PrintingPlugin");
printing_plugin_register_with_registrar(printing_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
Expand Down
1 change: 0 additions & 1 deletion demo/linux/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
printing
url_launcher_linux
)

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

import printing
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PrintingPlugin.register(with: registry.registrar(forPlugin: "PrintingPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
2 changes: 0 additions & 2 deletions demo/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ dependencies:
sdk: flutter
pluto_grid:
path: ../
pluto_grid_export:
path: ../packages/pluto_grid_export
faker: ^2.0.0
url_launcher: ^6.1.6
font_awesome_flutter: ^10.2.1
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,12 +6,9 @@

#include "generated_plugin_registrant.h"

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

void RegisterPlugins(flutter::PluginRegistry* registry) {
PrintingPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PrintingPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}
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
printing
url_launcher_windows
)

Expand Down
10 changes: 5 additions & 5 deletions demo/windows/runner/Runner.rc
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico"
// Version
//

#ifdef FLUTTER_BUILD_NUMBER
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
#else
#define VERSION_AS_NUMBER 1,0,0
#define VERSION_AS_NUMBER 1,0,0,0
#endif

#ifdef FLUTTER_BUILD_NAME
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
#if defined(FLUTTER_VERSION)
#define VERSION_AS_STRING FLUTTER_VERSION
#else
#define VERSION_AS_STRING "1.0.0"
#endif
Expand Down
2 changes: 2 additions & 0 deletions lib/src/widgets/pluto_scrollbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ class PlutoGridCupertinoScrollbarState extends State<PlutoScrollbar>
widget.verticalController?.position.viewportDimension,
axisDirection: widget.verticalController?.position.axisDirection ??
AxisDirection.down,
devicePixelRatio: 1.0,
);
}
break;
Expand All @@ -519,6 +520,7 @@ class PlutoGridCupertinoScrollbarState extends State<PlutoScrollbar>
axisDirection:
widget.horizontalController?.position.axisDirection ??
AxisDirection.right,
devicePixelRatio: 1.0,
);
}
break;
Expand Down
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ environment:
dependencies:
flutter:
sdk: flutter
intl: ^0.18.0
intl: ^0.18.1
rxdart: ^0.27.7
collection: ^1.17.0
collection: ^1.17.1

dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^5.3.2
build_runner: ^2.3.3
mockito: ^5.4.0
build_runner: ^2.4.2
flutter_lints: ^2.0.1
6 changes: 3 additions & 3 deletions test/helper/test_helper_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class TestHelperUtil {
required double width,
required double height,
}) async {
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
addTearDown(tester.view.resetPhysicalSize);

tester.binding.window.physicalSizeTestValue = Size(width, height);
tester.view.physicalSize = Size(width, height);

tester.binding.window.devicePixelRatioTestValue = 1.0;
tester.view.devicePixelRatio = 1.0;

await tester.pumpAndSettle();
}
Expand Down
Loading

0 comments on commit 6d1e224

Please sign in to comment.