🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / FLUTTER / mesaj yazdırmak toast print

1-) FLUTTER - mesaj yazdırmak toast print

 

************** HAZIR KÜTÜPHANE İLE  **************

 

Ekran Görüntüsü

 

info

 

error

 

okey

 

 

 

flutter pub add fluttertoast                  KAYNAK : https://pub.dev/packages/fluttertoast

 

1. StatikSinif.dart

 

 

class StatikSinif {

 

static void mesajYazOkey(FToast fToast,String mesaj){
    fToast.showToast(
        toastDuration:
Duration(seconds: 1),
        child:
Container(
          padding:
const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
          decoration:
BoxDecoration(
            borderRadius:
BorderRadius.circular(25.0),
            color:
Colors.blue,
          ),
          child:
Row(
            mainAxisSize:
MainAxisSize.min,
            children: [
             
Icon(Icons.offline_pin,color: Colors.white,),
              
SizedBox(
                width:
12.0,
              ),
              
Text(mesaj,style: TextStyle(fontSize: 13,fontWeight: FontWeight.bold,color: Colors.white),),
            ],
          ),
        )
    );
}

static void mesajYazInfo(FToast fToast,String mesaj){
  fToast.showToast(
      toastDuration:
Duration(seconds: 1),
      child:
Container(
        padding:
const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
        decoration:
BoxDecoration(
          borderRadius:
BorderRadius.circular(25.0),
          color:
ThemeProvider.themeOf(fToast.context!)
              .
data
              
.bottomAppBarColor,
        ),
        child:
Row(
          mainAxisSize:
MainAxisSize.min,
          children: [
            
Icon(Icons.info),
            
SizedBox(
              width:
12.0,
            ),
            
Text(mesaj,style: TextStyle(fontSize: 13,fontWeight: FontWeight.bold),),
          ],
        ),
      )
  );
}

static void mesajYazError(FToast fToast,String mesaj){
  fToast.showToast(
      toastDuration:
Duration(seconds: 1),
      child:
Container(
        padding:
const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
        decoration:
BoxDecoration(
          borderRadius:
BorderRadius.circular(25.0),
          color:
Colors.red.shade400,
        ),
        child:
Row(
          mainAxisSize:
MainAxisSize.min,
          children: [
            
Icon(Icons.error,color: Colors.white,),
            
SizedBox(
              width:
12.0,
            ),
            
Text(mesaj,style: TextStyle(fontSize: 13,fontWeight: FontWeight.bold,color: Colors.white),),
          ],
        ),
      )
  );
}}

 

 

2. Kullanimi.dart

 

 

late FToast fToast;

  
@override
  
void initState() {
    
super.initState();
    
fToast = FToast();
    
fToast.init(context);

  }

 

 

onPressed: () {
 
StatikSinif.mesajYazOkey(fToast,"KAYDEDİLDİ.");
},

 

 

 

 

************** DİĞER  **************

 

consoleye uzun mesaj yazdırmak istiyorsan örnek json -> log("asdasd") kullan

 

void mesajYaz(String text){
  
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
    duration:
const Duration(seconds: 1),
    content:
Text(text),
  ));
}

 

 

 

ScaffoldMessenger.of(context).showSnackBar(SnackBar(

duration: const Duration(seconds: 1),
  content:
Text("Hello World"),
));

 

veya

debugPrint('Card tapped.' + "$i");

veya

 print((sa.toInt()).toString());

 

 

 

 

 

 2023 Ocak 25 Çarşamba
 508