Last active
December 19, 2019 07:09
-
-
Save asavchuk/0c8dbd9449bf383715b9cea8507cc2c3 to your computer and use it in GitHub Desktop.
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 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatefulWidget { | |
@override | |
_MyAppState createState() => _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
void _getCsvDocunent(BuildContext ctx) async { | |
if (ctx != null) _showAlert(ctx, 'Hello world'); | |
} | |
Future _showAlert(BuildContext context, String message) async { | |
return showDialog( | |
context: context, | |
child: new AlertDialog( | |
title: new Text(message), | |
actions: <Widget>[ | |
new FlatButton( | |
onPressed: () => Navigator.pop(context), child: new Text('Ok')) | |
], | |
)); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('Plugin example app'), | |
), | |
body: Center( | |
child: Column( | |
children: <Widget>[ | |
FlatButton( | |
child: Text('Show alert'), | |
onPressed: () => _getCsvDocunent( | |
context), // показать алерт из _getCsvDocunent | |
), | |
], | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment