webcontent_converter 0.0.7+2 webcontent_converter: ^0.0.7+2 copied to clipboard
This plugin was made for developer to convert any webcontent, web uri to image bitmap or pdf file. This plugin use WebView on android, WKWebView on Ios and chromium for desktop support.
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:webcontent_converter/webcontent_converter.dart';
import 'package:window_manager/window_manager.dart';
import 'route.dart';
void main() async {
/// [make widget built before other configurations]
WidgetsFlutterBinding.ensureInitialized();
if (WebViewHelper.isDesktop) {
await windowManager.ensureInitialized();
/// ensure brower is initialized
await WebcontentConverter.ensureInitialized();
}
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WindowListener {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "webcontent converter",
initialRoute: "/",
routes: routes,
onGenerateRoute: onGenerateRoute,
);
}
@override
void initState() {
if (WebViewHelper.isDesktop) {
windowManager.addListener(this);
}
super.initState();
}
@override
void onWindowClose() {
log("onWindowClose");
/// auto close browser
if (WebViewHelper.isDesktop && windowBrower != null) {
WebcontentConverter.deinitWebcontentConverter();
}
super.onWindowClose();
}
@override
void dispose() {
if (WebViewHelper.isDesktop) {
windowManager.removeListener(this);
}
super.dispose();
}
}