Kutumia RawDialogRoute katika Flutter: Mwongozo na Mifano

RawDialogRoute ni darasa Flutter ambalo linawakilisha njia ghafi ya kidadisi, ikitoa njia ya kuonyesha mazungumzo maalum au madirisha ibukizi. Darasa hili kwa kawaida hutumiwa ndani na mfumo kuunda na kudhibiti njia za mazungumzo.

Huu hapa ni mfano wa jinsi unavyoweza kutumia RawDialogRoute kuonyesha mazungumzo maalum:

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'),  
       ),  
     ),  
   );  
  }  
}  

Katika mfano huu, kitufe kikibonyezwa, showDialog chaguo la kukokotoa hutumika kuonyesha mazungumzo maalum kwa kutumia RawDialogRoute kama kijenzi. Ndani ya builder, unaweza kutoa maudhui yako maalum kwa mazungumzo.

Tafadhali kumbuka kuwa hilo RawDialogRoute linaweza kuchukuliwa kuwa la kiwango cha chini, na unaweza kupata kufaa zaidi kutumia zilizojengewa ndani AlertDialog au SimpleDialog madarasa kuunda vidadisi mara nyingi.