This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| home: Scaffold( | |
| appBar: AppBar( | |
| title: Text("Abrir pdf"), | |
| ), | |
| body: Center( | |
| child: Builder( | |
| builder: (context) => Column( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String assetPDFPath = ""; | |
| String urlPDFPath = ""; | |
| @override | |
| void initState() { | |
| super.initState(); | |
| getFileFromAsset("assets/mypdf.pdf").then((f) { | |
| setState(() { | |
| assetPDFPath = f.path; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Future<File> getFileFromAsset(String asset) async { | |
| try { | |
| var data = await rootBundle.load(asset); | |
| var bytes = data.buffer.asUint8List(); | |
| var dir = await getApplicationDocumentsDirectory(); | |
| File file = File("${dir.path}/mi_archivo.pdf"); | |
| File assetFile = await file.writeAsBytes(bytes); | |
| return assetFile; | |
| } catch (e) { | |
| throw Exception("Error al abrir el archivo"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @override | |
| void initState() { | |
| refreshList(); | |
| super.initState(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:math'; | |
| final random = Random(); | |
| final refreshKey = GlobalKey<RefreshIndicatorState>(); | |
| var lista = []; | |
| Future<Null> refreshList() async { | |
| refreshKey.currentState?.show(atTop: false); | |
| await Future.delayed(Duration(seconds: 1)); | |
| setState(() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: Text("Hala para refrescar"), | |
| ), | |
| body: RefreshIndicator( | |
| key: refreshKey, | |
| child: ListView.builder( | |
| itemCount: lista.length, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Future<void> _autorizar() async { | |
| bool isAuthorized = false; | |
| try { | |
| isAuthorized = await _autenticacion.authenticateWithBiometrics( | |
| localizedReason: "Autentíquese para completar su transacción", | |
| useErrorDialogs: true, | |
| stickyAuth: true, | |
| ); | |
| } on PlatformException catch (e) { | |
| print(e); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Future<void> _listaAutenticacionesDisponibles() async { | |
| List<BiometricType> listaAutenticacion; | |
| try { | |
| listaAutenticacion = await _autenticacion.getAvailableBiometrics(); | |
| } on PlatformException catch (e) { | |
| print(e); | |
| } | |
| if (!mounted) return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Future<void> _probarAutorizacion() async { | |
| bool podemosUsarAutorizacion = false; | |
| try { | |
| podemosUsarAutorizacion = await _autenticacion.canCheckBiometrics; | |
| } on PlatformException catch (e) { | |
| print(e); | |
| } | |
| if (!mounted) return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final LocalAuthentication _autenticacion = LocalAuthentication(); | |
| bool _podemosUsarAutorizacion = false; | |
| String _autorizado = "No autorizado"; | |
| List<BiometricType> _autorizacionesDisponibles = List<BiometricType>(); |