Initial commit: Penyerahan final Source code Tugas Akhir
This commit is contained in:
53
lib/screens/course/component/pdfReader.dart
Normal file
53
lib/screens/course/component/pdfReader.dart
Normal file
@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:easy_pdf_viewer/easy_pdf_viewer.dart';
|
||||
import 'package:initial_folder/size_config.dart';
|
||||
import 'package:initial_folder/theme.dart';
|
||||
|
||||
class pdfReader extends StatefulWidget {
|
||||
final String link;
|
||||
final String title;
|
||||
const pdfReader({super.key, required this.link, required this.title});
|
||||
|
||||
@override
|
||||
State<pdfReader> createState() => _pdfReaderState();
|
||||
}
|
||||
|
||||
class _pdfReaderState extends State<pdfReader> {
|
||||
late PDFDocument document;
|
||||
bool _isLoading = true;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Load from URL
|
||||
loadPDF();
|
||||
}
|
||||
|
||||
void loadPDF() async {
|
||||
document = await PDFDocument.fromURL(widget.link);
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text(
|
||||
widget.title,
|
||||
style: secondaryTextStyle.copyWith(
|
||||
letterSpacing: 1,
|
||||
fontWeight: semiBold,
|
||||
fontSize: getProportionateScreenWidth(16)),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: _isLoading
|
||||
? Center(child: CircularProgressIndicator())
|
||||
: PDFViewer(
|
||||
document: document,
|
||||
pickerButtonColor: primaryColor,
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user