fahimkamal63

Snack Bar Flatter

Nov 30th, 2021
746
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'package:flutter/material.dart';
  2.  
  3. class SnackBarClass extends StatefulWidget {
  4.   const SnackBarClass({Key? key}) : super(key: key);
  5.  
  6.   @override
  7.   _SnackBarClassState createState() => _SnackBarClassState();
  8. }
  9.  
  10. class _SnackBarClassState extends State<SnackBarClass> {
  11.   @override
  12.   Widget build(BuildContext context) {
  13.     return Scaffold(
  14.       appBar: AppBar(title: Text("Snack Bar"), centerTitle: true,),
  15.       body: Center(
  16.         child: Builder(
  17.             builder: (BuildContext ctx){
  18.               return RaisedButton(
  19.                 onPressed: (){
  20.                   Scaffold.of(ctx).showSnackBar(
  21.                     SnackBar(
  22.                         content: Text("You have Pocked me!!")
  23.                     )
  24.                   );
  25.                 },
  26.                 child: Text("Pock Me"),
  27.               );
  28.             }
  29.         ),
  30.       ),
  31.     );
  32.   }
  33. }
  34.  
RAW Paste Data