SimpleDialog
SimpleDialog({ Widget title, List children, Color backgroundColor, double elevation, String semanticLabel, ShapeBorder shape })
açıklama
Basit iletişim kutusu oluşturur.Örneğin bir seçim listesi sunabilir.
parametreler
SimpleDialog( title: const Text('Select assignment'), children:[ SimpleDialogOption( onPressed: () { Navigator.pop(context, Department.treasury); }, child: const Text('Treasury department'), ), SimpleDialogOption( onPressed: () { Navigator.pop(context, Department.state); }, child: const Text('State department'), ), ], );
örnek uygulama
import 'package:flutter/material.dart'; import 'dart:async'; void main() { runApp(new MaterialApp( home: new MyApp() )); } class MyApp extends StatefulWidget { @override _State createState() => new _State(); } enum Answers{YES, NO, MAYBE} class _State extends State { String _value = ''; void _setValue(String value) => setState(() => _value = value); Future _askUser() async { switch( await showDialog( context: context, child: new SimpleDialog( title: new Text("Do you like flutter?"), children: [ new SimpleDialogOption( child: new Text("Yes"), onPressed: (){ Navigator.pop(context, Answers.YES); }, ), new SimpleDialogOption( child: new Text("No"), onPressed: (){ Navigator.pop(context, Answers.NO); }, ), new SimpleDialogOption( child: new Text("Maybe"), onPressed: (){ Navigator.pop(context, Answers.MAYBE); }, ) ], ) ) ) { case Answers.YES: _setValue('Yes'); break; case Answers.NO: _setValue("No"); break; case Answers.MAYBE: _setValue("Maybe"); break; } } @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text('Name here'), ), body: new Container( padding: new EdgeInsets.all(32.0), child: new Center( child: new Column( children: [ new Text(_value), new RaisedButton(onPressed: () => _askUser(), child: new Text("Click me"),) ], ), ), ), ); } }