Skip to content

Instantly share code, notes, and snippets.

@asavchuk
Last active December 19, 2019 07:09
Show Gist options
  • Save asavchuk/0c8dbd9449bf383715b9cea8507cc2c3 to your computer and use it in GitHub Desktop.
Save asavchuk/0c8dbd9449bf383715b9cea8507cc2c3 to your computer and use it in GitHub Desktop.
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