Skip to content

Commit

Permalink
Begun miration to dart 2
Browse files Browse the repository at this point in the history
Added dart2_constant as a polyfill for UTF8 constants that were renamed in dart 2
  • Loading branch information
orthros committed Aug 2, 2018
1 parent ef64441 commit 7aee898
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/src/readers/navigation_reader.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:async';
import 'dart:convert';

import 'package:xml/xml.dart' as xml;
import 'package:archive/archive.dart';
import 'package:dart2_constant/convert.dart' as convert;

import '../schema/navigation/epub_metadata.dart';
import '../schema/navigation/epub_navigation.dart';
Expand Down Expand Up @@ -52,7 +52,7 @@ class NavigationReader {
}

xml.XmlDocument containerDocument =
xml.parse(UTF8.decode(tocFileEntry.content));
xml.parse(convert.utf8.decode(tocFileEntry.content));

String ncxNamespace = "http://www.daisy.org/z3986/2005/ncx/";
xml.XmlElement ncxNode = containerDocument
Expand Down
4 changes: 2 additions & 2 deletions lib/src/readers/package_reader.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:async';
import 'dart:convert';

import 'package:archive/archive.dart';
import 'package:xml/xml.dart' as xml;
import 'package:dart2_constant/convert.dart' as convert;

import '../schema/opf/epub_guide.dart';
import '../schema/opf/epub_guide_reference.dart';
Expand All @@ -29,7 +29,7 @@ class PackageReader {
throw new Exception(
"EPUB parsing error: root file not found in archive.");
xml.XmlDocument containerDocument =
xml.parse(UTF8.decode(rootFileEntry.content));
xml.parse(convert.utf8.decode(rootFileEntry.content));
String opfNamespace = "http://www.idpf.org/2007/opf";
xml.XmlElement packageNode = containerDocument
.findElements("package", namespace: opfNamespace)
Expand Down
4 changes: 2 additions & 2 deletions lib/src/readers/root_file_path_reader.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:async';
import 'dart:convert';

import 'package:archive/archive.dart';
import 'package:xml/xml.dart' as xml;
import 'package:dart2_constant/convert.dart' as convert;

class RootFilePathReader {
static Future<String> getRootFilePath(Archive epubArchive) async {
Expand All @@ -17,7 +17,7 @@ class RootFilePathReader {
}

xml.XmlDocument containerDocument =
xml.parse(UTF8.decode(containerFileEntry.content));
xml.parse(convert.utf8.decode(containerFileEntry.content));
xml.XmlElement packageElement = containerDocument
.findAllElements("container",
namespace: "urn:oasis:names:tc:opendocument:xmlns:container")
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ref_entities/epub_content_file_ref.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:async';
import 'dart:convert';

import 'package:archive/archive.dart';
import 'package:dart2_constant/convert.dart' as convert;

import 'epub_book_ref.dart';
import '../entities/epub_content_type.dart';
Expand All @@ -26,7 +26,7 @@ abstract class EpubContentFileRef {

Future<String> readContentAsText() async {
List<int> contentStream = getContentStream();
String result = UTF8.decode(contentStream);
String result = convert.utf8.decode(contentStream);
return result;
}

Expand Down
7 changes: 4 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: epub
version: 1.2.10
author: Colin Nelson <[email protected]>
description: Epub Parser for Dart. Suitable for use on the Web or in Flutter
description: Epub Parser for Dart. Suitable for use on the Server, the Web, or in Flutter
homepage: https://github.com/orthros/dart-epub
environment:
sdk: ">=1.21.0 <2.0.1"
sdk: ">=1.24.0 <3.0.0"
dependencies:
async: ">=1.8.0 <2.1.0"
archive: "^1.0.33"
xml: ">=2.6.0 <4.0.0"
image: "^1.1.30"
image: ">=1.1.33 <3.0.0"
dart2_constant: ^1.0.1
dev_dependencies:
test: "^0.12.0"
path: "^1.5.1"

0 comments on commit 7aee898

Please sign in to comment.