flutter_pdf_dade 1.0.0
flutter_pdf_dade: ^1.0.0 copied to clipboard
A new Flutter Plugin
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter_pdf/flutter_pdf.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
Future<void> _initData() async {
String jsonInfo =
"{\"bookId\":\"0000000001\",\"bookPath\":\"222222222\",\"pageIndex\":0}";
String pdfInfo = await FlutterPdf.readPdf(jsonInfo);
// ignore: avoid_print
print(pdfInfo);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: MaterialButton(
onPressed: _initData,
textColor: Colors.white,
color: Colors.blue,
// ignore: prefer_const_constructors
child: Text("打开文件"),
),
),
),
);
}
/// 处理点击按钮背景颜色
/// 设置当前按钮为不可点击时,设置onPressed回调为null。
MaterialStateProperty<Color> createTextBtnBgColor() {
return MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.pressed)) {
return Colors.blueGrey;
} else if (states.contains(MaterialState.disabled)) {
return Colors.blueAccent;
}
return Colors.blue;
///扩展String函数
});
}
}