RawDialogRoute
aji ne a cikin Flutter wannan yana wakiltar danyen hanyar tattaunawa, yana ba da hanya don nuna maganganu na al'ada ko bugu. Yawanci ana amfani da wannan ajin a ciki ta tsarin don ƙirƙira da sarrafa hanyoyin tattaunawa.
Ga misalin yadda zaku yi amfani da shi RawDialogRoute
don nuna maganganun al'ada:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('RawDialogRoute Example'),
),
body: Center(
child: ElevatedButton(
onPressed:() {
showDialog(
context: context,
builder:(BuildContext context) {
return RawDialogRoute(
context: context,
barrierDismissible: true,
builder:(BuildContext context) {
return AlertDialog(
title: Text('Custom Dialog'),
content: Text('This is a custom dialog using RawDialogRoute.'),
actions: [
TextButton(
onPressed:() {
Navigator.pop(context);
},
child: Text('Close'),
),
],
);
},
);
},
);
},
child: Text('Open Dialog'),
),
),
);
}
}
A cikin wannan misali, lokacin da aka danna maɓallin, showDialog
ana amfani da aikin don nuna maganganun al'ada ta amfani da RawDialogRoute
maginin. A cikin builder
, zaku iya samar da abun ciki na al'ada don maganganun.
Da fatan za a lura cewa RawDialogRoute
ana iya ɗaukar wannan ƙaramin aji, kuma kuna iya samun ya fi dacewa don amfani da ginin ciki AlertDialog
ko SimpleDialog
azuzuwan don ƙirƙirar tattaunawa a mafi yawan lokuta.