diff --git a/.gitignore b/.gitignore
index 9505a1c..e86f310 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,10 +5,10 @@
.pub/
pubspec.lock
-/.idea/
+.idea/
build/
# generated files not to be checked in
flutter_export_environment.sh
.flutter-plugins-dependencies
-Flutter.podspec
\ No newline at end of file
+Flutter.podspec
diff --git a/analysis_options.yaml b/analysis_options.yaml
new file mode 100644
index 0000000..a5744c1
--- /dev/null
+++ b/analysis_options.yaml
@@ -0,0 +1,4 @@
+include: package:flutter_lints/flutter.yaml
+
+# Additional information about this file can be found at
+# https://dart.dev/guides/language/analysis-options
diff --git a/android/.gitignore b/android/.gitignore
index c6cbe56..91e5885 100644
--- a/android/.gitignore
+++ b/android/.gitignore
@@ -6,3 +6,4 @@
.DS_Store
/build
/captures
+.idea/
diff --git a/android/build.gradle b/android/build.gradle
index ed99534..8990414 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,15 +1,15 @@
-group 'com.afur.flutterhtmltopdf'
+group 'com.afur.flutter_html_to_pdf'
version '1.0-SNAPSHOT'
buildscript {
- ext.kotlin_version = '1.3.21'
+ ext.kotlin_version = '1.3.50'
repositories {
google()
- jcenter()
+ mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.3.2'
+ classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@@ -17,7 +17,7 @@ buildscript {
rootProject.allprojects {
repositories {
google()
- jcenter()
+ mavenCentral()
}
}
@@ -25,17 +25,23 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
- compileSdkVersion 28
+ compileSdkVersion 30
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
+
defaultConfig {
minSdkVersion 16
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- }
- lintOptions {
- disable 'InvalidPackage'
}
}
diff --git a/android/gradle.properties b/android/gradle.properties
index 8bd86f6..94adc3a 100644
--- a/android/gradle.properties
+++ b/android/gradle.properties
@@ -1 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..3c9d085
--- /dev/null
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
index 1956efa..595dc51 100644
--- a/android/src/main/AndroidManifest.xml
+++ b/android/src/main/AndroidManifest.xml
@@ -1,4 +1,3 @@
-
+ package="com.afur.flutter_html_to_pdf">
diff --git a/android/src/main/kotlin/android/print/PdfPrinter.kt b/android/src/main/kotlin/android/print/PdfPrinter.kt
index 714b0e4..aeb9a18 100644
--- a/android/src/main/kotlin/android/print/PdfPrinter.kt
+++ b/android/src/main/kotlin/android/print/PdfPrinter.kt
@@ -13,30 +13,43 @@ class PdfPrinter(private val printAttributes: PrintAttributes) {
}
- fun print(printAdapter: PrintDocumentAdapter, path: File, fileName: String, callback: PdfPrinter.Callback) {
+ fun print(
+ printAdapter: PrintDocumentAdapter,
+ path: File,
+ fileName: String,
+ callback: Callback
+ ) {
// Support for min API 16 is required
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- printAdapter.onLayout(null, printAttributes, null, object : PrintDocumentAdapter.LayoutResultCallback() {
+ printAdapter.onLayout(
+ null,
+ printAttributes,
+ null,
+ object : PrintDocumentAdapter.LayoutResultCallback() {
- override fun onLayoutFinished(info: PrintDocumentInfo, changed: Boolean) {
- printAdapter.onWrite(arrayOf(PageRange.ALL_PAGES), getOutputFile(path, fileName),
- CancellationSignal(), object : PrintDocumentAdapter.WriteResultCallback() {
+ override fun onLayoutFinished(info: PrintDocumentInfo, changed: Boolean) {
+ printAdapter.onWrite(arrayOf(PageRange.ALL_PAGES),
+ getOutputFile(path, fileName),
+ CancellationSignal(),
+ object : PrintDocumentAdapter.WriteResultCallback() {
- override fun onWriteFinished(pages: Array) {
- super.onWriteFinished(pages)
+ override fun onWriteFinished(pages: Array) {
+ super.onWriteFinished(pages)
- if (pages.isEmpty()) {
- callback.onFailure()
- }
+ if (pages.isEmpty()) {
+ callback.onFailure()
+ }
- File(path, fileName).let {
- callback.onSuccess(it.absolutePath)
- }
+ File(path, fileName).let {
+ callback.onSuccess(it.absolutePath)
+ }
- }
- })
- }
- }, null)
+ }
+ })
+ }
+ },
+ null
+ )
}
}
}
@@ -47,7 +60,7 @@ private fun getOutputFile(path: File, fileName: String): ParcelFileDescriptor {
path.mkdirs()
}
- File(path, fileName).let{
+ File(path, fileName).let {
it.createNewFile()
return ParcelFileDescriptor.open(it, ParcelFileDescriptor.MODE_READ_WRITE)
}
diff --git a/android/src/main/kotlin/com/afur/flutter_html_to_pdf/FlutterHtmlToPdfPlugin.kt b/android/src/main/kotlin/com/afur/flutter_html_to_pdf/FlutterHtmlToPdfPlugin.kt
new file mode 100644
index 0000000..fe9600f
--- /dev/null
+++ b/android/src/main/kotlin/com/afur/flutter_html_to_pdf/FlutterHtmlToPdfPlugin.kt
@@ -0,0 +1,49 @@
+package com.afur.flutter_html_to_pdf
+
+import android.content.Context
+import androidx.annotation.NonNull
+
+import io.flutter.embedding.engine.plugins.FlutterPlugin
+import io.flutter.plugin.common.MethodCall
+import io.flutter.plugin.common.MethodChannel
+import io.flutter.plugin.common.MethodChannel.MethodCallHandler
+import io.flutter.plugin.common.MethodChannel.Result
+
+/** FlutterHtmlToPdfPlugin */
+class FlutterHtmlToPdfPlugin: FlutterPlugin, MethodCallHandler {
+ private lateinit var channel : MethodChannel
+ private lateinit var applicationContext: Context
+
+ override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
+ channel = MethodChannel(flutterPluginBinding.binaryMessenger, "flutter_html_to_pdf")
+ channel.setMethodCallHandler(this)
+
+ applicationContext = flutterPluginBinding.applicationContext
+ }
+
+ override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
+ if (call.method == "convertHtmlToPdf") {
+ convertHtmlToPdf(call, result)
+ } else {
+ result.notImplemented()
+ }
+ }
+
+ override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
+ channel.setMethodCallHandler(null)
+ }
+
+ private fun convertHtmlToPdf(call: MethodCall, result: Result) {
+ val htmlFilePath = call.argument("htmlFilePath")
+
+ HtmlToPdfConverter().convert(htmlFilePath!!, applicationContext, object : HtmlToPdfConverter.Callback {
+ override fun onSuccess(filePath: String) {
+ result.success(filePath)
+ }
+
+ override fun onFailure() {
+ result.error("ERROR", "Unable to convert html to pdf document!", "")
+ }
+ })
+ }
+}
diff --git a/android/src/main/kotlin/com/afur/flutterhtmltopdf/HtmlToPdfConverter.kt b/android/src/main/kotlin/com/afur/flutter_html_to_pdf/HtmlToPdfConverter.kt
similarity index 63%
rename from android/src/main/kotlin/com/afur/flutterhtmltopdf/HtmlToPdfConverter.kt
rename to android/src/main/kotlin/com/afur/flutter_html_to_pdf/HtmlToPdfConverter.kt
index 7b791e8..8d6144e 100644
--- a/android/src/main/kotlin/com/afur/flutterhtmltopdf/HtmlToPdfConverter.kt
+++ b/android/src/main/kotlin/com/afur/flutter_html_to_pdf/HtmlToPdfConverter.kt
@@ -1,6 +1,7 @@
-package com.afur.flutterhtmltopdf
+package com.afur.flutter_html_to_pdf
-import android.app.Activity
+import android.annotation.SuppressLint
+import android.content.Context
import android.os.Build
import android.print.PdfPrinter
import android.print.PrintAttributes
@@ -17,29 +18,30 @@ class HtmlToPdfConverter {
fun onFailure()
}
- fun convert(filePath: String, activity: Activity, callback: Callback) {
- val webView = WebView(activity.applicationContext)
+ @SuppressLint("SetJavaScriptEnabled")
+ fun convert(filePath: String, applicationContext: Context, callback: Callback) {
+ val webView = WebView(applicationContext)
val htmlContent = File(filePath).readText(Charsets.UTF_8)
- webView.getSettings().setJavaScriptEnabled(true);
- webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
- webView.getSettings().setAllowFileAccess(true);
+ webView.settings.javaScriptEnabled = true
+ webView.settings.javaScriptCanOpenWindowsAutomatically = true
+ webView.settings.allowFileAccess = true
webView.loadDataWithBaseURL(null, htmlContent, "text/HTML", "UTF-8", null)
webView.webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView, url: String) {
super.onPageFinished(view, url)
- createPdfFromWebView(webView, activity, callback)
+ createPdfFromWebView(webView, applicationContext, callback)
}
}
}
- fun createPdfFromWebView(webView: WebView, activity: Activity, callback: Callback) {
- val path = activity.applicationContext.filesDir
+ fun createPdfFromWebView(webView: WebView, applicationContext: Context, callback: Callback) {
+ val path = applicationContext.filesDir
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
val attributes = PrintAttributes.Builder()
- .setMediaSize(PrintAttributes.MediaSize.ISO_A4)
- .setResolution(PrintAttributes.Resolution("pdf", "pdf", 600, 600))
- .setMinMargins(PrintAttributes.Margins.NO_MARGINS).build()
+ .setMediaSize(PrintAttributes.MediaSize.ISO_A4)
+ .setResolution(PrintAttributes.Resolution("pdf", "pdf", 600, 600))
+ .setMinMargins(PrintAttributes.Margins.NO_MARGINS).build()
val printer = PdfPrinter(attributes)
diff --git a/android/src/main/kotlin/com/afur/flutterhtmltopdf/FlutterHtmlToPdfPlugin.kt b/android/src/main/kotlin/com/afur/flutterhtmltopdf/FlutterHtmlToPdfPlugin.kt
deleted file mode 100644
index 029f44b..0000000
--- a/android/src/main/kotlin/com/afur/flutterhtmltopdf/FlutterHtmlToPdfPlugin.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.afur.flutterhtmltopdf
-
-import io.flutter.plugin.common.MethodCall
-import io.flutter.plugin.common.MethodChannel
-import io.flutter.plugin.common.MethodChannel.MethodCallHandler
-import io.flutter.plugin.common.MethodChannel.Result
-import io.flutter.plugin.common.PluginRegistry.Registrar
-
-class FlutterHtmlToPdfPlugin(private val registrar: Registrar) : MethodCallHandler {
-
- companion object {
- @JvmStatic
- fun registerWith(registrar: Registrar) {
- val channel = MethodChannel(registrar.messenger(), "flutter_html_to_pdf")
- channel.setMethodCallHandler(FlutterHtmlToPdfPlugin(registrar))
- }
- }
-
- override fun onMethodCall(call: MethodCall, result: Result) {
- if (call.method == "convertHtmlToPdf") {
- convertHtmlToPdf(call, result)
- } else {
- result.notImplemented()
- }
- }
-
- private fun convertHtmlToPdf(call: MethodCall, result: Result) {
- val htmlFilePath = call.argument("htmlFilePath")
-
- HtmlToPdfConverter().convert(htmlFilePath!!, registrar.activity(), object : HtmlToPdfConverter.Callback {
- override fun onSuccess(filePath: String) {
- result.success(filePath)
- }
-
- override fun onFailure() {
- result.error("ERROR", "Unable to convert html to pdf document!", "")
- }
- })
- }
-}
-
diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml
new file mode 100644
index 0000000..61b6c4d
--- /dev/null
+++ b/example/analysis_options.yaml
@@ -0,0 +1,29 @@
+# This file configures the analyzer, which statically analyzes Dart code to
+# check for errors, warnings, and lints.
+#
+# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
+# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
+# invoked from the command line by running `flutter analyze`.
+
+# The following line activates a set of recommended lints for Flutter apps,
+# packages, and plugins designed to encourage good coding practices.
+include: package:flutter_lints/flutter.yaml
+
+linter:
+ # The lint rules applied to this project can be customized in the
+ # section below to disable rules from the `package:flutter_lints/flutter.yaml`
+ # included above or to enable additional rules. A list of all available lints
+ # and their documentation is published at
+ # https://dart-lang.github.io/linter/lints/index.html.
+ #
+ # Instead of disabling a lint rule for the entire project in the
+ # section below, it can also be suppressed for a single line of code
+ # or a specific dart file by using the `// ignore: name_of_lint` and
+ # `// ignore_for_file: name_of_lint` syntax on the line or in the file
+ # producing the lint.
+ rules:
+ # avoid_print: false # Uncomment to disable the `avoid_print` rule
+ # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
+
+# Additional information about this file can be found at
+# https://dart.dev/guides/language/analysis-options
diff --git a/example/android/.gitignore b/example/android/.gitignore
new file mode 100644
index 0000000..6f56801
--- /dev/null
+++ b/example/android/.gitignore
@@ -0,0 +1,13 @@
+gradle-wrapper.jar
+/.gradle
+/captures/
+/gradlew
+/gradlew.bat
+/local.properties
+GeneratedPluginRegistrant.java
+
+# Remember to never publicly share your keystore.
+# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
+key.properties
+**/*.keystore
+**/*.jks
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index 3c57234..b0ed919 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -26,24 +26,28 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
- compileSdkVersion 28
+ compileSdkVersion 30
- sourceSets {
- main.java.srcDirs += 'src/main/kotlin'
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+ kotlinOptions {
+ jvmTarget = '1.8'
}
- lintOptions {
- disable 'InvalidPackage'
+ sourceSets {
+ main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
- applicationId "com.afur.flutterhtmltopdfexample"
+ applicationId "com.afur.flutter_html_to_pdf_example"
minSdkVersion 16
- targetSdkVersion 28
+ targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -61,7 +65,4 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test:runner:1.1.0'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml
new file mode 100644
index 0000000..a3ddd75
--- /dev/null
+++ b/example/android/app/src/debug/AndroidManifest.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 5f414d9..c63d539 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -1,40 +1,41 @@
-
-
-
-
-
-
-
+
-
+
+ android:name="io.flutter.embedding.android.NormalTheme"
+ android:resource="@style/NormalTheme"
+ />
+
+
+
+
diff --git a/example/android/app/src/main/kotlin/com/afur/flutter_html_to_pdf_example/MainActivity.kt b/example/android/app/src/main/kotlin/com/afur/flutter_html_to_pdf_example/MainActivity.kt
new file mode 100644
index 0000000..6ecbd6f
--- /dev/null
+++ b/example/android/app/src/main/kotlin/com/afur/flutter_html_to_pdf_example/MainActivity.kt
@@ -0,0 +1,6 @@
+package com.afur.flutter_html_to_pdf_example
+
+import io.flutter.embedding.android.FlutterActivity
+
+class MainActivity: FlutterActivity() {
+}
diff --git a/example/android/app/src/main/kotlin/com/afur/flutterhtmltopdfexample/MainActivity.kt b/example/android/app/src/main/kotlin/com/afur/flutterhtmltopdfexample/MainActivity.kt
deleted file mode 100644
index d65103d..0000000
--- a/example/android/app/src/main/kotlin/com/afur/flutterhtmltopdfexample/MainActivity.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.afur.flutterhtmltopdfexample
-
-import android.os.Bundle
-
-import io.flutter.app.FlutterActivity
-import io.flutter.plugins.GeneratedPluginRegistrant
-
-class MainActivity: FlutterActivity() {
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- GeneratedPluginRegistrant.registerWith(this)
- }
-}
diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml
new file mode 100644
index 0000000..f74085f
--- /dev/null
+++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml
new file mode 100644
index 0000000..449a9f9
--- /dev/null
+++ b/example/android/app/src/main/res/values-night/styles.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml
index 00fa441..d74aa35 100644
--- a/example/android/app/src/main/res/values/styles.xml
+++ b/example/android/app/src/main/res/values/styles.xml
@@ -1,8 +1,18 @@
-
+
+
diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml
new file mode 100644
index 0000000..a3ddd75
--- /dev/null
+++ b/example/android/app/src/profile/AndroidManifest.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/example/android/build.gradle b/example/android/build.gradle
index 1f0933b..ed45c65 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -1,12 +1,12 @@
buildscript {
- ext.kotlin_version = '1.3.21'
+ ext.kotlin_version = '1.3.50'
repositories {
google()
- jcenter()
+ mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.4.0'
+ classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@@ -14,15 +14,13 @@ buildscript {
allprojects {
repositories {
google()
- jcenter()
+ mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
-}
-subprojects {
project.evaluationDependsOn(':app')
}
diff --git a/example/android/gradle.properties b/example/android/gradle.properties
index 53ae0ae..94adc3a 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -1,3 +1,3 @@
-android.enableJetifier=true
-android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index 8850d34..bc6a58a 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Jul 16 17:03:26 CEST 2019
+#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
diff --git a/example/android/settings.gradle b/example/android/settings.gradle
index 5a2f14f..44e62bc 100644
--- a/example/android/settings.gradle
+++ b/example/android/settings.gradle
@@ -1,15 +1,11 @@
include ':app'
-def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
+def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
+def properties = new Properties()
-def plugins = new Properties()
-def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
-if (pluginsFile.exists()) {
- pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
-}
+assert localPropertiesFile.exists()
+localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
-plugins.each { name, path ->
- def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
- include ":$name"
- project(":$name").projectDir = pluginDirectory
-}
+def flutterSdkPath = properties.getProperty("flutter.sdk")
+assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
+apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
diff --git a/example/ios/.gitignore b/example/ios/.gitignore
new file mode 100644
index 0000000..e20cf8d
--- /dev/null
+++ b/example/ios/.gitignore
@@ -0,0 +1,75 @@
+*.mode1v3
+*.mode2v3
+*.moved-aside
+*.pbxuser
+*.perspectivev3
+**/*sync/
+.sconsign.dblite
+.tags*
+**/.vagrant/
+**/DerivedData/
+Icon?
+**/Pods/
+**/.symlinks/
+profile
+xcuserdata
+**/.generated/
+Flutter/App.framework
+Flutter/Flutter.framework
+Flutter/Flutter.podspec
+Flutter/Generated.xcconfig
+Flutter/ephemeral/
+Flutter/app.flx
+Flutter/app.zip
+Flutter/flutter_assets/
+Flutter/flutter_export_environment.sh
+ServiceDefinitions.json
+Runner/GeneratedPluginRegistrant.*
+
+# Exceptions to above rules.
+!default.mode1v3
+!default.mode2v3
+!default.pbxuser
+!default.perspectivev3
+
+
+
+# Created by https://www.toptal.com/developers/gitignore/api/xcode
+# Edit at https://www.toptal.com/developers/gitignore?templates=xcode
+
+### Xcode ###
+# Xcode
+#
+# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
+
+## User settings
+xcuserdata/
+
+## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
+*.xcscmblueprint
+*.xccheckout
+
+## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
+build/
+DerivedData/
+*.moved-aside
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+
+## Gcc Patch
+/*.gcno
+
+### Xcode Patch ###
+*.xcodeproj/*
+!*.xcodeproj/project.pbxproj
+!*.xcodeproj/xcshareddata/
+!*.xcworkspace/contents.xcworkspacedata
+**/xcshareddata/WorkspaceSettings.xcsettings
+
+# End of https://www.toptal.com/developers/gitignore/api/xcode
diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart
new file mode 100644
index 0000000..d61f707
--- /dev/null
+++ b/example/test/widget_test.dart
@@ -0,0 +1,27 @@
+// This is a basic Flutter widget test.
+//
+// To perform an interaction with a widget in your test, use the WidgetTester
+// utility that Flutter provides. For example, you can send tap and scroll
+// gestures. You can also use WidgetTester to find child widgets in the widget
+// tree, read text, and verify that the values of widget properties are correct.
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+import 'package:flutter_html_to_pdf_example/main.dart';
+
+void main() {
+ testWidgets('Verify Platform version', (WidgetTester tester) async {
+ // Build our app and trigger a frame.
+ await tester.pumpWidget(const MyApp());
+
+ // Verify that platform version is retrieved.
+ expect(
+ find.byWidgetPredicate(
+ (Widget widget) => widget is Text &&
+ widget.data!.startsWith('Running on:'),
+ ),
+ findsOneWidget,
+ );
+ });
+}
diff --git a/ios/.gitignore b/ios/.gitignore
index 710ec6c..5d0836e 100644
--- a/ios/.gitignore
+++ b/ios/.gitignore
@@ -1,36 +1,74 @@
-.idea/
-.vagrant/
+*.mode1v3
+*.mode2v3
+*.moved-aside
+*.pbxuser
+*.perspectivev3
+**/*sync/
.sconsign.dblite
-.svn/
-
-.DS_Store
-*.swp
+.tags*
+**/.vagrant/
+**/DerivedData/
+Icon?
+**/Pods/
+**/.symlinks/
profile
+xcuserdata
+**/.generated/
+Flutter/App.framework
+Flutter/Flutter.framework
+Flutter/Flutter.podspec
+Flutter/Generated.xcconfig
+Flutter/ephemeral/
+Flutter/app.flx
+Flutter/app.zip
+Flutter/flutter_assets/
+Flutter/flutter_export_environment.sh
+ServiceDefinitions.json
+Runner/GeneratedPluginRegistrant.*
-DerivedData/
-build/
-GeneratedPluginRegistrant.h
-GeneratedPluginRegistrant.m
+# Exceptions to above rules.
+!default.mode1v3
+!default.mode2v3
+!default.pbxuser
+!default.perspectivev3
-.generated/
-*.pbxuser
-*.mode1v3
-*.mode2v3
-*.perspectivev3
+# Created by https://www.toptal.com/developers/gitignore/api/xcode
+# Edit at https://www.toptal.com/developers/gitignore?templates=xcode
+
+### Xcode ###
+# Xcode
+#
+# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
+
+## User settings
+xcuserdata/
+
+## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
+*.xcscmblueprint
+*.xccheckout
+## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
+build/
+DerivedData/
+*.moved-aside
+*.pbxuser
!default.pbxuser
+*.mode1v3
!default.mode1v3
+*.mode2v3
!default.mode2v3
+*.perspectivev3
!default.perspectivev3
-xcuserdata
-
-*.moved-aside
+## Gcc Patch
+/*.gcno
-*.pyc
-*sync/
-Icon?
-.tags*
+### Xcode Patch ###
+*.xcodeproj/*
+!*.xcodeproj/project.pbxproj
+!*.xcodeproj/xcshareddata/
+!*.xcworkspace/contents.xcworkspacedata
+**/xcshareddata/WorkspaceSettings.xcsettings
-/Flutter/Generated.xcconfig
+# End of https://www.toptal.com/developers/gitignore/api/xcode
diff --git a/pubspec.yaml b/pubspec.yaml
index 00a4d7b..3aadd3c 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -23,7 +23,7 @@ flutter:
plugin:
platforms:
android:
- package: com.afur.flutterhtmltopdf
+ package: com.afur.flutter_html_to_pdf
pluginClass: FlutterHtmlToPdfPlugin
ios:
pluginClass: FlutterHtmlToPdfPlugin
diff --git a/test/flutter_html_to_pdf_test.dart b/test/flutter_html_to_pdf_test.dart
new file mode 100644
index 0000000..04ec692
--- /dev/null
+++ b/test/flutter_html_to_pdf_test.dart
@@ -0,0 +1,23 @@
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:flutter_html_to_pdf/flutter_html_to_pdf.dart';
+
+void main() {
+ const MethodChannel channel = MethodChannel('flutter_html_to_pdf');
+
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ setUp(() {
+ channel.setMockMethodCallHandler((MethodCall methodCall) async {
+ return '42';
+ });
+ });
+
+ tearDown(() {
+ channel.setMockMethodCallHandler(null);
+ });
+
+ test('getPlatformVersion', () async {
+ expect(await FlutterHtmlToPdf.platformVersion, '42');
+ });
+}