我的应用程序在打开使用syncfusion_flutter_pdfviewer的页面时遇到错误

gv8xihay  于 2023-04-22  发布在  Flutter
关注(0)|答案(1)|浏览(167)

我想使用syncfusion_flutter_pdfviewer包显示PDF。

这是我做的步骤

1.创建包含syncfusion_flutter_pdfviewer的页面。
1.然后,我在我的设备上运行应用程序
1.出现错误消息,其中包含以下消息:与设备的连接丢失

代码示例

import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:miniawradreborn/page/appbar_page.dart';
import 'package:miniawradreborn/page/model_list.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';

import 'list_page.dart';

class single_list extends StatefulWidget {
  final List<Model_list> Modellist;
  int index;
  final List<Model_pdf> Modelpdf;

  single_list(
      {super.key,
      required this.Modellist,
      required this.index,
      required this.Modelpdf});

  @override
  State<single_list> createState() => _single_listState();
}

class _single_listState extends State<single_list> {
  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;

    return Scaffold(
      body: SingleChildScrollView(
        child: Column(
          children: [
            AppBar_normalpage(judul: widget.Modellist[widget.index].nama),
            Container(
              decoration: BoxDecoration(color: Colors.white),
              width: MediaQuery.of(context).size.width,
              height: 600,
              margin: EdgeInsets.all(20),
              // padding: EdgeInsets.all(20),
              child: Container(
                child: SfPdfViewer.asset(
                  widget.Modelpdf[widget.index].pdf!,
                  enableDoubleTapZooming: true,
                  pageSpacing: 0,
                  initialZoomLevel: 0,
                  pageLayoutMode: PdfPageLayoutMode.continuous,
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}

日志

Running "flutter pub get" in miniawradreborn...
Resolving dependencies...
  async 2.10.0 (2.11.0 available)
  characters 1.2.1 (1.3.0 available)
  collection 1.17.0 (1.17.1 available)
  js 0.6.5 (0.6.7 available)
  matcher 0.12.13 (0.12.14 available)
  material_color_utilities 0.2.0 (0.3.0 available)
  meta 1.8.0 (1.9.0 available)
  path 1.8.2 (1.8.3 available)
  path_provider_foundation 2.1.3 (2.2.0 available)
  petitparser 5.1.0 (5.3.0 available)
  syncfusion_flutter_core 20.4.53 (20.4.54 available)
  syncfusion_flutter_pdf 20.4.53 (20.4.54 available)
  syncfusion_flutter_pdfviewer 20.4.53 (20.4.54 available)
  syncfusion_pdfviewer_macos 20.4.53 (20.4.54 available)
  syncfusion_pdfviewer_platform_interface 20.4.53 (20.4.54 available)
  syncfusion_pdfviewer_web 20.4.53 (20.4.54 available)
  syncfusion_pdfviewer_windows 20.4.53 (20.4.54 available)
  test_api 0.4.16 (0.4.18 available)
  win32 3.1.3 (4.1.1 available)
These packages are no longer being depended on:
- flutter_pdfview 1.2.9
Changed 1 dependency!
Launching lib\main.dart on SM N960F in debug mode...
Parameter format not correct -
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Error: ADB exited with exit code 1
Uninstalling old version...
Performing Streamed Install

adb: failed to install D:\MediaTech\Cyber\Aplikasi\Aplikasi Mini Awrad Santri\miniawradreborn\build\app\outputs\flutter-apk\app-debug.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.example.miniawradreborn signatures do not match previously installed version; ignoring!]
Connecting to VM Service at ws://127.0.0.1:50117/KFclYh_Urt4=/ws
[GETX] Instance "GetMaterialController" has been created
[GETX] Instance "GetMaterialController" has been initialized
I/miniawradrebor(19078): Compiler allocated 4218KB to compile void android.view.ViewRootImpl.performTraversals()
W/Gralloc3(19078): mapper 3.x is not supported
I/gralloc (19078): Arm Module v1.0
I/OpenGLRenderer(19078): doUpdatePositionAsync is called and callVoidMethod
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/miniawradrebor(19078): Background young concurrent copying GC freed 319(134KB) AllocSpace objects, 13(2788KB) LOS objects, 35% free, 5309KB/8237KB, paused 116us total 114.373ms
I/miniawradrebor(19078): Background concurrent copying GC freed 43(56KB) AllocSpace objects, 7(5060KB) LOS objects, 66% free, 3120KB/9264KB, paused 55us total 272.349ms
D/InputMethodManager(19078): prepareNavigationBarInfo() DecorView@9f28167[MainActivity]
D/InputMethodManager(19078): getNavigationBarColor() -855310
V/InputMethodManager(19078): Starting input: tba=com.example.miniawradreborn ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
D/InputMethodManager(19078): startInputInner - Id : 0
I/InputMethodManager(19078): startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport(19078): Input channel destroyed: 'ClientS', fd=94
D/InputMethodManager(19078): prepareNavigationBarInfo() DecorView@9f28167[MainActivity]
D/InputMethodManager(19078): getNavigationBarColor() -855310
V/InputMethodManager(19078): Starting input: tba=com.example.miniawradreborn ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
D/InputMethodManager(19078): startInputInner - Id : 0
I/InputMethodManager(19078): startInputInner - mService.startInputOrWindowGainedFocus
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/miniawradrebor(19078): NativeAlloc concurrent copying GC freed 528(152KB) AllocSpace objects, 10(3924KB) LOS objects, 74% free, 2078KB/8222KB, paused 108us total 111.658ms
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 0
I/ViewRootImpl@81bcd03[MainActivity](19078): ViewPostIme pointer 1
Lost connection to device.
Exited (sigterm)

扑医生

flutter doctor -v
[√] Flutter (Channel stable, 3.7.2-0.0.pre.1, on Microsoft Windows [Version 10.0.19043.1645], locale en-ID)
    • Flutter version 3.7.2-0.0.pre.1 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a40e08605f (2 weeks ago), 2023-03-01 00:40:27 +0700
    • Engine revision 800594f1f4
    • Dart version 2.19.1
    • DevTools version 2.20.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at C:\Users\cyber\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.4.33213.308
    • Windows 10 SDK version 10.0.20348.0

[√] Android Studio (version 2021.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] VS Code (version 1.76.2)
    • VS Code at C:\Users\cyber\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.61.20230301

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19043.1645]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 111.0.5563.65
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 111.0.1661.41

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

我希望显示包含syncfusion_flutter_pdfviewer的PDF的页面

wz3gfoph

wz3gfoph1#

请验证widget.Modelpdf[widget.index].pdf!是否为File类型?
如果是文件路径,则必须使用
File(widget.Modelpdf[widget.index].pdf!)
这应该能解决你的问题至少对我来说解决了。

相关问题