Flutter Toast in Sinhala

Flutter Toast in Sinhala

Flutter Toast එක කේතයක් පමණක් ලිවීමෙන් ටෝස්ට් පණිවිඩයක් නිර්මාණය කිරීමට භාවිතා කරයි. Flutter හි Flutter Toast නිර්මාණය කිරීමට පියවර කිහිපයක් පහත දැක්වේ. මූලික වශයෙන්, අපි විධාන විමසුමක් භාවිතා කරමින් නව Flutter යෙදුමක් නිර්මාණය කරමු.

 

  • main.dart ගොනුවෙන් පෙරනිමි කේතය මකා ඔබේම කේතය ලියන්න.

  • Now, add fluttertoast in dependencies of the pubspec.yaml file:

 

 

 

 

Properties of showToast:

  • msg: toast message.

  • toastLength: Duration of toast

  • backgroundColor: Background color to be shown.

  • textColor: Text color to be shown.

  • fontSize: Font size of toast message.

 

import 'package:flutter/material.dart';


import 'package:fluttertoast/fluttertoast.dart';


void main() {


runApp(const MyApp());


}


class MyApp extends StatelessWidget {


const MyApp({Key? key}) : super(key: key);


// This widget is the


// root of your application.


@override


Widget build(BuildContext context) {


return MaterialApp(


title: "Flutter Demo",


theme: ThemeData(


primarySwatch: Colors.blue,


),


debugShowCheckedModeBanner: false,


home: const MyHomePage(),


);


}


}


class MyHomePage extends StatefulWidget {


const MyHomePage({Key? key}) : super(key: key);


@override


// ignore: library_private_types_in_public_api


_MyHomePageState createState() => _MyHomePageState();


}


class _MyHomePageState extends State {


@override


Widget build(BuildContext context) {


return Scaffold(


appBar: AppBar(


title: const Text("GeeksforGeeks"),


backgroundColor: Colors.green,


),


body: Center(


child: TextButton(


onPressed: () {


Fluttertoast.showToast(


msg: 'Apps Lanka Dev',


backgroundColor: Colors.grey,


);


},


}


}


 We are developing Mobile application and Web application for more details visit our web site www.appslanka.lk

0 Comments

Leave a comment

Your email address will not be published. Required fields are marked *