I added a package power file view to view different files now I want to do some changes inside this package like the language by default is Chinese I want to convert it to English. someone, please.
CodePudding user response:
Editing a package after adding it to pubspec.yaml is not recommended. Because, when you upgrade it to a later version, all changes that you made will go useless.
If you want to make changes to a package, go to the GitHub repository of the package, then download the whole project or copy the required class files from /lib folder.
Then make changes to required files and copy it to your project. Read the license file of the package carefully before making any changes.
CodePudding user response:
I beleive they use webview to render files. You cannot change the default language.
According to package description:
Android uses Tencent TBS service, supports preview of doc, docx, ppt, pptx, xls, xlsx, pdf, txt, epub files
ios uses WKWebView, all supported by WKWebView can be previewed
You can use webview_flutter
to render supported files as well.
var file_link ='https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf';
WebView(
initialUrl: 'https://docs.google.com/gview?embedded=true&url=$file_link',
);
for older version of webview_flutter
for webview_flutter: 4.0.0
above
import 'package:flutter/widgets.dart';
import 'package:webview_flutter/webview_flutter.dart';
class DocsView extends StatelessWidget {
DocsView({super.key, required this.url});
final String url;
final controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setBackgroundColor(const Color(0x00000000))
..setNavigationDelegate(
NavigationDelegate(
onProgress: (int progress) {
// Update loading bar.
},
onPageStarted: (String url) {},
onPageFinished: (String url) {},
onWebResourceError: (WebResourceError error) {},
onNavigationRequest: (NavigationRequest request) {
return NavigationDecision.navigate;
},
),
);
@override
Widget build(BuildContext context) {
controller.loadRequest(
Uri.parse(('https://docs.google.com/gview?embedded=true&url=$url')));
return WebViewWidget(
controller: controller,
);
}
}
use it like :
DocsView(url:'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf');