Language: 中文 | English
At present, the plugin is only used by Android, iOS.
Android is implemented by Tencent X5.
iOS is implemented by WKWebView.
docx,doc,xlsx,xls,pptx,ppt,pdf,txt
docx,doc,xlsx,xls,pptx,ppt,pdf,txt
FlutterFileView.init();
@override
Widget build(BuildContext context) {
return LocalFileViewer(filePath: localPath ?? '');
}
@override
Widget build(BuildContext context) {
return FileView(
controller: FileViewController.asset('assets/files/$filePath'),
);
}
There are still many usages of FileViewController at present, such as the representation of some states and so on.
dio
to make network requests. sdk: ">=2.14.0 <3.0.0"
flutter: ">=2.5.0"
flutter_file_view
to pubspec.yaml
dependencies.dependencies:
flutter_file_view: ^latest_version
flutter pub get
import 'package:flutter_file_view/flutter_file_view.dart';
Add in MaterialApp
.
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
...
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
...
ViewerLocalizationsDelegate.delegate,
],
...
);
}
}
Add a piece of code in label application
on AndroidManifst.xml
file
android:networkSecurityConfig="@xml/network_security_config"
android:usesCleartextTraffic="true"
Add a file named network_security_config.xml
in res/xml
directory, The content of the file is
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
If you like my project, please in the upper right corner of the project "Star". Your support is my biggest encouragement! ^_^