In my software, I take advantage of the flutter_pdfview:^1.2.7 package deal to show a pdf file that’s pulled from the community.
Beforehand, it’s saved on the consumer’s machine.
The applying works accurately in debugging mode and doesn’t warn about any errors. However once I created an ipa file and launched it on my machine, then within the widget the place I show a pdf doc or a picture from the community, I simply get a grey container.
What am I doing fallacious?
pdf_screen
import 'package deal:flutter/materials.dart';
import 'package deal:flutter_pdfview/flutter_pdfview.dart';
import 'package deal:cell/app/app.dart';
import 'package deal:cell/area/area.dart';
import '../widgets/widgets.dart';
class DocumentPreview extends StatefulWidget {
const DocumentPreview({
required this.title,
required this.file,
required this.deleteFunction,
tremendous.key,
});
ultimate String title;
ultimate FilePreview file;
ultimate void Operate()? deleteFunction;
@override
State<DocumentPreview> createState() => _DocumentPreviewState();
}
class _DocumentPreviewState extends State<DocumentPreview> {
int _totalPages = 1;
int _currentPage = 1;
@override
Widget construct(BuildContext context) {
ultimate theme = Theme.of(context);
return Scaffold(
backgroundColor: theme.palette.bgPrimary,
appBar: AppBar(
title: Textual content(
context.l10n.viewingDocumentTitle,
type: theme.textTheme.titleLarge,
),
),
bottomSheet: BottomPanelPreview(
currentPage: _currentPage,
lengthPages: _totalPages,
file: widget.file,
onPressed: widget.deleteFunction,
),
physique: Padding(
padding: EdgeInsets.symmetric(
horizontal: theme.spacings.x4,
vertical: theme.spacings.x4,
),
baby: Column(
crossAxisAlignment: CrossAxisAlignment.begin,
kids: [
Text(
widget.title,
style: theme.textTheme.titleSmall,
textAlign: TextAlign.left,
),
SizedBox(
height: theme.spacings.x3,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
widget.file.name,
style: theme.textTheme.bodyMedium!.copyWith(
color: theme.palette.textSecondary,
),
),
),
SizedBox(
width: theme.spacings.x5,
),
Text(
'${widget.file.size.toStringAsFixed(1)} КБ',
style: theme.textTheme.bodyMedium!.copyWith(
color: theme.palette.textSecondary,
),
),
],
),
SizedBox(
peak: theme.spacings.x6,
),
Heart(
baby: SizedBox(
peak: MediaQuery.of(context).dimension.peak * 0.6,
baby: DecoratedBox(
ornament: BoxDecoration(
border: Border.all(
colour: theme.palette.buttonDisabled,
),
borderRadius: BorderRadius.round(
theme.spacings.x2,
),
),
baby: Expanded(
baby: ClipRRect(
borderRadius: BorderRadius.round(
theme.spacings.x2,
),
baby: widget.file.sort.toLowerCase() == 'pdf'
? PDFView(
swipeHorizontal: true,
filePath: widget.file.file!.path,
onRender: (pages) {
setState(() {
_totalPages = pages!;
});
},
onPageChanged: (int? web page, int? whole) {
setState(() {
_currentPage = web page!+1;
});
},
)
: Picture.community(
widget.file.hyperlink,
match: BoxFit.fill,
),
),
),
),
),
),
SizedBox(
peak: theme.spacings.x15,
),
],
),
),
);
}
}
get_pdf
ultimate response = await http.get(Uri.parse(url));
ultimate bytes = response.bodyBytes;
ultimate dir = await getApplicationSupportDirectory();
ultimate file = File('${dir.path}/contract.pdf');
await file.writeAsBytes(bytes, flush: true);
return file;
bloc
Future<void> _onGetFileForViewing(GetFileEvent occasion,
Emitter<SigningDocumentsState> emit,) async {
emit(
SigningDocumentsState(
standing: SigningDocumentsStatus.loading,
scans: state.scans,
),
);
attempt {
if (occasion.information.identify
.cut up('.')
.final == 'pdf') {
ultimate response = await _clientRepository.getPdf(
url: occasion.information.information.first.hyperlink,
);
emit(
SigningDocumentsState(
standing: SigningDocumentsStatus.loaded,
scans: state.scans,
currentPdfFile: response,
currentFile: occasion.information,
title: occasion.title,
),
);
} else {
emit(
SigningDocumentsState(
standing: SigningDocumentsStatus.loaded,
scans: state.scans,
currentFile: occasion.information,
title: occasion.title,
),
);
}
} on Exception {
emit(
SigningDocumentsState(
standing: SigningDocumentsStatus.failure,
scans: state.scans,
),
);
}
}
data.plist
<plist model="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>$(FLAVOR_APP_NAME)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>ru</string>
</array>
<key>CFBundleName</key>
<string>Synergy Join</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>FlutterDeepLinkingEnabled</key>
<true/>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>Used to add doc photos</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Used to add doc photos</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Fundamental</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>