Advertisement
muhaiminurabir

server error dialog flutter

Jul 3rd, 2025
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 5.10 KB | None | 0 0
  1.   void showServerErrorDialog() {
  2.     BuildContext dContext =
  3.         GlobalVariableKeys.navigatorState.currentState!.overlay!.context;
  4.     showGeneralDialog(
  5.       barrierLabel: "Label",
  6.       barrierDismissible: false,
  7.       barrierColor: Colors.black.withAlpha(50),
  8.       transitionDuration: Duration(milliseconds: 500),
  9.       context: dContext,
  10.       pageBuilder: (dialogContext, anim1, anim2) {
  11.         return PopScope(
  12.           canPop: false,
  13.           onPopInvokedWithResult: (didPop, result) {
  14.             false;
  15.           },
  16.           child: Align(
  17.             alignment: Alignment.center,
  18.             child: SingleChildScrollView(
  19.               physics: const ScrollPhysics(),
  20.               child: Padding(
  21.                 padding: const EdgeInsets.all(24.0),
  22.                 child: Card(
  23.                   elevation: 0,
  24.                   shape: const RoundedRectangleBorder(
  25.                     borderRadius: BorderRadius.all(Radius.circular(12)),
  26.                   ),
  27.                   child: Padding(
  28.                     padding: const EdgeInsets.all(24.0),
  29.                     child: Column(
  30.                       mainAxisSize: MainAxisSize.max,
  31.                       crossAxisAlignment: CrossAxisAlignment.stretch,
  32.                       children: [
  33.                         SvgPicture.asset(
  34.                           "assets/images/exclamatory.svg",
  35.                           height: 40,
  36.                           width: 40,
  37.                         ),
  38.                         SizedBox(height: 10),
  39.                         Text(
  40.                           "Service Down",
  41.                           style: GoogleFonts.poppins(
  42.                             fontSize: 20,
  43.                             fontWeight: FontWeight.w500,
  44.                             color: ProjectColors.black4,
  45.                           ),
  46.                           maxLines: 1,
  47.                           overflow: TextOverflow.ellipsis,
  48.                           softWrap: true,
  49.                           textAlign: TextAlign.center,
  50.                         ),
  51.                         SizedBox(height: 10),
  52.                         Text(
  53.                           "Apologies, our servers are temporarily down. We are working hard to resolve the issue and get everything back up and running as soon as possible",
  54.                           style: GoogleFonts.poppins(
  55.                             fontSize: 14,
  56.                             fontWeight: FontWeight.w400,
  57.                             color: ProjectColors.black4,
  58.                           ),
  59.                           overflow: TextOverflow.ellipsis,
  60.                           softWrap: true,
  61.                           maxLines: 6,
  62.                           textAlign: TextAlign.center,
  63.                         ),
  64.                         SizedBox(height: 12),
  65.                         ElevatedButton(
  66.                           style: ButtonStyle(
  67.                             padding: WidgetStateProperty.all<EdgeInsets>(
  68.                               EdgeInsets.all(12),
  69.                             ),
  70.                             foregroundColor: WidgetStateProperty.all<Color>(
  71.                               ProjectColors.gray,
  72.                             ),
  73.                             backgroundColor: WidgetStateProperty.all<Color>(
  74.                               ProjectColors.gray,
  75.                             ),
  76.                             shape:
  77.                                 WidgetStateProperty.all<RoundedRectangleBorder>(
  78.                                   RoundedRectangleBorder(
  79.                                     borderRadius: BorderRadius.circular(8.0),
  80.                                     side: BorderSide(color: ProjectColors.gray),
  81.                                   ),
  82.                                 ),
  83.                           ),
  84.                           onPressed: () {
  85.                             if (Platform.isAndroid) {
  86.                               SystemNavigator.pop();
  87.                             } else if (Platform.isIOS) {
  88.                               exit(0);
  89.                             }
  90.                           },
  91.                           child: Text(
  92.                             "Got It",
  93.                             style: GoogleFonts.poppins(
  94.                               fontSize: 14,
  95.                               fontWeight: FontWeight.w400,
  96.                               color: ProjectColors.black4,
  97.                             ),
  98.                             maxLines: 1,
  99.                             overflow: TextOverflow.ellipsis,
  100.                             softWrap: true,
  101.                             textAlign: TextAlign.center,
  102.                           ),
  103.                         ),
  104.                       ],
  105.                     ),
  106.                   ),
  107.                 ),
  108.               ),
  109.             ),
  110.           ),
  111.         );
  112.       },
  113.       transitionBuilder: (context, anim1, anim2, child) {
  114.         return SlideTransition(
  115.           position: Tween(
  116.             begin: Offset(0, 1),
  117.             end: Offset(0, 0),
  118.           ).animate(anim1),
  119.           child: child,
  120.         );
  121.       },
  122.     );
  123.   }
  124.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement