Flutter Text Button Widget in Sinhala

Flutter Text Button Widget in Sinhala

 

Text Button යනු Google හි Material Design Library වෙතින් එහි සැලසුම ලබා ගන්නා  Flutter හි ඇති බිල්ට් විජට් එකකි. එය onPressed සහ onLongPress අභිනයන් සඳහා සවන් දෙන කිසිදු මායිමක් නොමැති සරල බොත්තමකි. එයට ButtonStyle අගයක් ලෙස පිළිගන්නා මෝස්තර දේපලක් ඇත, මෙම ශෛලිය භාවිතා කරමින් දේපල සංවර්ධකයින්ට ඔවුන්ට අවශ්‍ය පරිදි TextButton අභිරුචිකරණය කළ හැකිය.

The constructor of TextButton Class:

const TextButton({

  Key? key,

  required void Function()? onPressed,

  void Function()? onLongPress,

  void Function(bool)? onHover,

  void Function(bool)? onFocusChange,

  ButtonStyle? style,

  FocusNode? focusNode,

  bool autofocus = false,

  Clip clipBehavior = Clip.none,

  required Widget child,

})

Properties of TextButton Widget:

  • onPressed: (required) This property takes a Function that returns void. That function will be invoked whenever the TextButton is pressed.

  • onLongPress: This property also takes a Function that returns void. That function will be invoked whenever the TextButton is long pressed.

  • onHover: onHover property takes a void Function which takes a boolean value as its only parameter. The passed parameter is true if a pointer entered the button response area and is false when a pointer leaves the button response area.

  • onFocusChange: onFocusChange property also takes a void Function which takes a boolean value as its only parameter. The passed parameter is true if the button gains focus and is false if the button loses focus.

  • style: This optional property accepts ButtonStyle as an object. It is used for customizing the look of the TextButton.

  • focusNode: An optional focus node to use as the focus node for TextButton.

  • autofocus: Pass true if you want this widget as the initial focus when no other node in its scope is currently focused. The default value is false.

  • clipBehaviour: Accept value of type Clip enum. The default value is Clip.none.

  • child: (required) The child widget of TextButton Widget.

Example1: In the example below, we used TextButton’s onPressed property to launch the URL when we press the TextButton.

 import 'package:flutter/material.dart';

import 'package:url_launcher/url_launcher.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: 'Apps Lanka Dev',

theme: ThemeData(

primarySwatch: Colors.green,

),

home: const Home(),

);

}

}

 

class Home extends StatelessWidget {

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

 

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(

title: Text("Apps Lanka Dev"),

),

body: Center(

child: Column(

mainAxisAlignment: MainAxisAlignment.center,

children: [

Padding(

padding: const EdgeInsets.only(bottom: 35),

child: TextButton(

child: Text(

"Press Apps Lanka",

style: TextStyle(fontSize: 25),

),

onPressed: () async {

const String _url = "https://appslanka.lk/";

if (await canLaunch(_url)) {

launch(_url);

} else {

throw "Could not launch $_url";

}

},

)

],

),

),

);

}

}

 


 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 *