Flutter GetX paketi, kolay ve hızlı bir şekilde dialoglar oluşturmak için kullanabileceğiniz Get.dialog() fonksiyonunu sağlar.
Get.dialog(
AlertDialog(
title: Text('Merhaba!'),
content: Text('Dialog kullanımı öğreniyorum.'),
actions: [
TextButton(
onPressed: () => Get.back(),
child: Text('Kapat'),
),
],
),
);Örneğin, bir butona tıklama işlemi sonrası bir dialog göstermek istediğinizi varsayalım. İşte bu senaryo için bir örnek kod:
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Dialog Kullanımı'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
Get.dialog(
AlertDialog(
title: Text('Merhaba!'),
content: Text('Dialog kullanımı öğreniyorum.'),
actions: [
TextButton(
onPressed: () => Get.back(),
child: Text('Kapat'),
),
],
),
);
},
child: Text('Dialog Göster'),
),
),
);
}
}
