How to launch a link in Flutter? - flutter

I'm trying to launch a URL link in ElevatedButton but it doesn't work if I press the button it does not do anything, is there a different thing that works with ElevatedButton or should I write a different label
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter/material.dart';
class MyAppThree extends StatefulWidget {
const MyAppThree({super.key});
#override
State<StatefulWidget> createState() => _MyAppThreeState();
}
class _MyAppThreeState extends State<StatefulWidget> {
_launchURL() async {
const url = 'https://www.youtube.com/';
final uri = Uri.parse(url);
if (await canLaunchUrl(uri)) {
await launchUrl(uri);
} else {
throw 'Could not launch $url';
}
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.black,
title: const Text(''),
),
body: Container(
child: Column(
children: <Widget>[
ElevatedButton(
onPressed: _launchURL,
child: Text(
'TAG Here',
style: TextStyle(
color: Colors.white,
fontSize: 20,
),
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
const Color.fromARGB(255, 55, 55, 55)),
),
),

Starting on Android 11 (API 30), you must add a element in the Android manifest as a child of the root element:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourapp">
<queries>
<!-- If your app checks for https -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
/* rest of the manifest */
</manifest>

Related

Multiple issues in my AndroidManifest.xml with my flutter App

I want to launch my App to the Playstore.
So I changed my minSdkVersion in the app\build.gradle from 16 to 31.
But now, when I build my Appbundle I encountered this error.
Execution failed for task ':app:processReleaseMainManifest'.
Manifest merger failed : android:exported needs to be explicitly specified for element <activity#com.example.debt.MainActivity>.
Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding compon
ent has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.debt">
<application
android:label="Money Reminder"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
`
import 'package:flutter/material.dart';
import 'package:debt/colors.dart';
import 'package:debt/add.dart';
import 'package:debt/data.dart';
import 'package:flutter/foundation.dart';
import 'package:hive_flutter/hive_flutter.dart';
late Box box;
List<Data>datalist=[];
Future <void> main() async{
WidgetsFlutterBinding.ensureInitialized();
await Hive.initFlutter();
Hive.registerAdapter(DataAdapter());
box = await Hive.openBox("infos");
//wandelt die daten für die Anzeige um
Map<dynamic, dynamic> data2 = box.toMap();
//macht aus map liste
data2.forEach((key, value) {
if(kDebugMode){
Data w =Data (key, value);
datalist.add(w);
}
});
runApp(const MaterialApp(
home: debt(),
debugShowCheckedModeBanner: false,
));}
// ignore: camel_case_types
class debt extends StatefulWidget {
const debt({Key? key}) : super(key: key);
#override
_debtState createState() => _debtState();
}
// ignore: camel_case_types
class _debtState extends State<debt> {
Map<String, dynamic> values = {};
String text = 'Text';
double w = 100;
double h = 20;
Widget quoteTemplate(data){
return ValueListenableBuilder<Box>(
valueListenable: Hive.box('infos').listenable(),
builder: (context, box, widget) {
return
Card(
margin: const EdgeInsets.fromLTRB(16, 16, 16, 0),
child:Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, // x Achse
crossAxisAlignment: CrossAxisAlignment.center, // y Achse
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, // x Achse
crossAxisAlignment: CrossAxisAlignment.center,// y Achse
children: <Widget>[
Container(alignment: Alignment.center,
width: 100,
height: h,
child: Text(
data.people,
style: TextStyle(
fontSize: 18,
color: Colors.grey[600],
)
),
),
const SizedBox(height: 6,),
Container(
alignment: Alignment.center,
child: Text(
data.money,
style: TextStyle(
fontSize: 14,
color: Colors.grey[800],
)
),
),
],
)
,Container(//delete
alignment: Alignment.center,
child: TextButton(style: TextButton.styleFrom(
),
onPressed: (){
box.delete(data.people);
setState(() {
Map<dynamic, dynamic> data2 = box.toMap();
datalist=[];
data2.forEach((key, value) {
if(kDebugMode){
Data w =Data (key, value);
datalist.add(w);
}
});
});
},
child: const Icon(Icons.delete,color: lightblue,),
),
),
Container(//minusbutton
alignment: Alignment.center,
child: TextButton(style: TextButton.styleFrom(//Minus Butten
),
onPressed: (){
var zwischenspeicher = box.get(data.people);
double zwischenspeicher2= double.parse(zwischenspeicher) - 1.0;
var schulden = zwischenspeicher2.toString();
box.put(data.people,schulden);
//Updatet das widget
setState(() {
Map<dynamic, dynamic> data2 = box.toMap();
datalist=[];
data2.forEach((key, value) {
if(kDebugMode){
Data w =Data (key, value);
datalist.add(w);
}
});
});
},
child: const Icon(Icons.remove,color: darkblue,),
),
),
Container(//plus Button
alignment: Alignment.center,
child: TextButton(style: TextButton.styleFrom(
),
onPressed: (){
var zwischenspeicher = box.get(data.people);
var zwischenspeicher2= double.parse(zwischenspeicher) + 1;
var schulden = zwischenspeicher2.toString();
box.put(data.people,schulden);
setState(() {
Map<dynamic, dynamic> data2 = box.toMap();
datalist=[];
data2.forEach((key, value) {
if(kDebugMode){
Data w =Data (key, value);
datalist.add(w);
}
});
});
},
child: const Icon(Icons.add,color: darkbrown,),
),
),
],
),
);});
}Widget buttond(){
return
Padding(
padding: const EdgeInsets.all(8.0),
child: Expanded(child: Align(
alignment: FractionalOffset.bottomRight,
child:
FloatingActionButton(
onPressed: () {
_awaitReturnValueFromSecondScreen(context);
},
child: const Icon(Icons.add),backgroundColor: lightbrown,
),),),
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: lightblue ,
title: const Text("Money Reminder"),
centerTitle: true,
),
body:
Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
children: [
Column(
children: datalist.map((data)=> quoteTemplate(data)).toList(),
),
],
),
),bottomNavigationBar: Padding(
padding: const EdgeInsets.fromLTRB(20,0,20,10),
child:
ElevatedButton(
onPressed: () {
_awaitReturnValueFromSecondScreen(context);
},
//child: const Icon(Icons.add,color: Colors.white,),
child: const Text('add/edit debt',style: TextStyle(fontSize: 18,fontFamily: "Futura",color: Colors.white),),
style: ElevatedButton.styleFrom( backgroundColor:lightbrown,)
)
),
);
}
void _awaitReturnValueFromSecondScreen(BuildContext context) async {
// start the SecondScreen and wait for it to finish with a result
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const add(),
));
// after the SecondScreen result comes back update the Text widget with it
setState(() {
datalist = result;
});
}
}
`
The Problems of the manifest:
https://i.stack.imgur.com/kcZWN.png
https://i.stack.imgur.com/7lkfx.png
I tryed to Invalidate the cashe.
Write like this in your AndroidManifest.xml file activity.
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:exported="true"
tools:node="merge">

I am developing application where I only used share package, since then I keep receiving errors

I am developing application where I only used share package, since then I keep receiving errors that i didnt even how to fix them.
I am developing application where I only used share package, since then I keep receiving errors that i didnt even how to fix them.
here is my code
import 'package:flutter/material.dart';
import 'package:share/share.dart';
import 'nupe_file.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
#override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final controller = TextEditingController();
List<WordList> words = dictionary;
List<String> listWords = worda;
List<String> listMeanings = meaninga;
share(BuildContext context,) {
final RenderObject? box = context.findRenderObject();
Share.share(
'https://play.google.com/store/apps/details?id=com.codingempirenigeria.fadlullahibilhakimusa',
);
}
aboutMsg(BuildContext context){
return showDialog(
context: context,
builder: (context){
return AlertDialog(
title: Text('About The App'),
content: Container(
child: Column(
children: [
Text('some information about the application')
]
)
),
actions: [
FlatButton(
child: Text('OK'),
onPressed: () => Navigator.pop(context)
),
FlatButton(
child: Text('Share'),
onPressed: share(context)
)
]
);
}
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Center(
child: Text('Nupe / English Dictionary'),
),
actions: [
IconButton(
icon: Icon(Icons.message_rounded, size: 30),
onPressed: (){aboutMsg(context);},
)
],
elevation: 0.0,
),
body: Container(
child: Column(
children: [
Container(
color: Colors.blue,
padding: EdgeInsets.fromLTRB(10, 0, 10, 10),
child: TextField(
controller: controller,
scrollPadding: EdgeInsets.all(50),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(top: 5, left:15),
filled: true,
fillColor: Colors.white,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),
),
hintText: 'Enter Nupe/English Word...',
suffixIcon: Icon(Icons.search)
),
onChanged: search,
),
),
Container(
child: Expanded(
child: ListView.builder(
itemCount: words.length,
itemBuilder: (BuildContext contex, int index){
final word = words[index];
final listWord = listWords[index];
final listMeaning = listMeanings[index];
return ListTile(
tileColor: Colors.white,
onTap: null,
title: Text(word.word,
style: TextStyle(color: Colors.black,
fontWeight: FontWeight.bold,
),
),
subtitle: Text(word.meaning,
style: TextStyle(color: Colors.black),
),
);
}
),
),
)
],
),
),
);
}
void search(String value) {
final suggestions = dictionary.where((word) {
final wordd = word.word.toLowerCase();
final input = value.toLowerCase();
return wordd.contains(input);
}).toList();
setState(() => words = suggestions);
}
}
here is error I keep recieving
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/mime-1.0.2/lib/src/mime_multipart_transformer.dart: Error: The control character U+0000 can only be used in strings and comments.
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/mime-1.0.2/lib/src/mime_type.dart: Error: The control character U+0000 can only be used in strings and comments.
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/share-2.0.4/lib/share.dart:99:12: Error: Method not found: 'lookupMimeType'.
return lookupMimeType(path) ?? 'application/octet-stream';
^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1102
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4m 58s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
Use this flutter_share: ^2.0.0 package
Future<void> share() async {
await FlutterShare.share(
title: 'Example share',
text: 'Example share text',
linkUrl: 'https://flutter.dev/',
chooserTitle: 'Example Chooser Title');
}

How to implement this custom slider flutter

I am trying to implement this custom slider on my flutter app. I have searched most of the open source libraries but I cannot seem to get the one that suits my need.
The closet I got to is Cupertino Slider but I couldn't customize it to fit my need. Any ideas?
this is what you are looking for, slider_button:
SliderButton(
action: () {
///Do something here OnSlide
},
///Put label over here
label: Text(
"Slide to cancel !",
style: TextStyle(
color: Color(0xff4a4a4a),
fontWeight: FontWeight.w500,
fontSize: 17),
),
icon: Center(
child: Icon(
Icons.power_settings_new,
color: Colors.white,
size: 40.0,
semanticLabel: 'Text to announce in accessibility modes',
)),
///Change All the color and size from here.
width: 230,
radius: 10,
buttonColor: Color(0xffd60000),
backgroundColor: Color(0xff534bae),
highlightedColor: Colors.white,
baseColor: Colors.red,
);
Try this:
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
class View extends StatefulWidget {
const View({Key? key}) : super(key: key);
#override
_ViewState createState() => _ViewState();
}
class _ViewState extends State<View> {
int segmentedControlGroupValue = 0;
final Map<int, Widget> myTabs = const <int, Widget>{
0: Icon(Icons.arrow_forward, color: Colors.white,),
1: Text("Start Shopping", style: TextStyle(color: Colors.orange),)
};
#override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: CupertinoSlidingSegmentedControl(
backgroundColor: Colors.orange.withOpacity(0.2),
groupValue: segmentedControlGroupValue,
thumbColor: CupertinoColors.activeOrange,
children: myTabs,
onValueChanged: (newValue) {
setState(() {
segmentedControlGroupValue = newValue as int;
});
}),
),
);
}
}

show next or previous Array word on onclick?

Hello friends I am creating learning app I need little help here I have array list when anyone click any word it goes to next sacreen user go to next sacreen instead user come back to pervious sacreen for next word I want user click on next button or pervious button to show next word pervious word on same sacreen.instead coming back to my previous word how it possible and remember array word must shown from right left because it an Hebrew language app here my image and code?
enter image description here
enter image description here
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'Sounds.dart';
class Kamiz extends StatefulWidget {
#override
_KamizState createState() => _KamizState();
}
class _KamizState extends State<Kamiz> {
var kamiz=['פָּרָ','חָםָ','נָבָּ','עָוָ','אָםָ','מָרָ','כָּכָּ','מָמָ','פָּפָּ','בָּרָ','קָרָ','דָּרָ','וָרָ','הָרָ','תָּרָ','בָּם','כָּלָ','כָּר','שָׁלָ','סָרָ','כָּכָּ','אָםָ','חָםָ','אָל','כָּלָ'];
var list=['57.wav','48.wav','47.wav','46.wav','45.wav','55.wav','54.wav','53.wav','51.wav','50.wav','60.wav','61.wav','58.wav',
'57.wav','61.wav','65.wav','64.wav','63.wav','62.wav','missing.wav','70.wav','69.wav','48.wav','67.wav','66.wav'
];
var urduvowel=['پارا','خاما','نابا','عاوا','آما','مارا','کاکا','ماما','پاپا','بارا','قارا','دارا','وارا','ہارا','تارا','باما',
'کالا','کارا','شالا','سارا','کاکا','آما','خاما','الا','کالا'];
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Kamatz',style:GoogleFonts.davidLibre(
fontSize: 24,
fontWeight: FontWeight.bold,
)),
),
body: GridView.builder(
itemCount: kamiz.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 5,
),
itemBuilder: (BuildContext context,int index){
return Padding(
padding:EdgeInsets.all(10.0),
child: GestureDetector(
onTap: () {
Navigator.push (
context,
MaterialPageRoute(builder: (context) => Sounds(kamiz[index],list[index],urduvowel[index])),
);
},
child: Container(
decoration: BoxDecoration(
color: Colors.black12,
border: Border.all(color: Colors.blueAccent)
),
child: Center(
child: Directionality(
textDirection: TextDirection.rtl,
child: Column(
children: [
Text(kamiz[index],style:GoogleFonts.davidLibre(
fontSize: 16,
fontWeight: FontWeight.bold,
)),
Text(urduvowel[index],style:GoogleFonts.davidLibre(
fontSize: 16,
fontWeight: FontWeight.bold,
)),
],
),
),
),
),
),
) ;
}
)
);
}
}
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:audioplayers/audioplayers.dart';
import 'package:flutter_cache_manager_firebase/flutter_cache_manager_firebase.dart';
class Sounds extends StatefulWidget {
#override
_SoundsState createState() => _SoundsState();
String word;
var sounds;
var urdu;
Sounds(this.word,this.sounds,this.urdu);
}
class _SoundsState extends State<Sounds> {
final Completer<WebViewController> _controller = Completer<WebViewController>();
var audio;
AudioPlayer audioPlayer = AudioPlayer();
#override
void initState() {
super.initState();
audio='''
<!DOCTYPE html>
<html>
<body>
<audio id="englishAudio">
<source src="https://firebasestorage.googleapis.com/v0/b/hebrewapp-453d2.appspot.com/o/practicesounds%2F${widget.sounds}?alt=media&token=603fc7fc-6794-424d-84c6-3627d0d81d68" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<button onclick="UrduAudio()" type="button">Listen Word</button>
<button onclick="pauseAudio()" type="button">Pause Audio</button>
<script>
var x = document.getElementById("englishAudio");
var y = document.getElementById("urduAudio");
function UrduAudio() {
x.play();
}
function englishAudio() {
y.play();
}
function pauseAudio() {
x.pause();
y.pause();
}
</script>
</body>
</html>
''';
}
#override
Widget build(BuildContext context) {
#override
String audioplay='''
<!DOCTYPE html>
<html>
<body>
<audio id="englishAudio">
<source src="https://firebasestorage.googleapis.com/v0/b/hebrewapp-453d2.appspot.com/o/practicesounds%2F${widget.sounds}?alt=media&token=603fc7fc-6794-424d-84c6-3627d0d81d68" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<button onclick="UrduAudio()" type="button">Listen Word</button>
<button onclick="pauseAudio()" type="button">Pause Audio</button>
<script>
var x = document.getElementById("englishAudio");
var y = document.getElementById("urduAudio");
function UrduAudio() {
x.play();
}
function englishAudio() {
y.play();
}
function pauseAudio() {
x.pause();
y.pause();
}
</script>
</body>
</html>
''';
return Scaffold(
appBar: AppBar(
title: Text(
'Kamatz',style:GoogleFonts.davidLibre(
fontSize: 24,
fontWeight: FontWeight.bold,
)),
),
body: Center(
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
widget.urdu+'/'+widget.word,style:GoogleFonts.davidLibre(
fontSize: 70,
)),
SizedBox(height: 30,),
Center(
child: Padding(
padding:EdgeInsets.only(left: 90),
child: Container(
constraints: BoxConstraints(maxHeight: 100,),
child: WebView(
initialUrl:Uri.dataFromString(audio, mimeType: 'text/html').toString(),
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
}, //
)
),
),
),
Padding(
padding:EdgeInsets.only(left: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('PERV'),
Icon(
Icons.arrow_left,
size: 70.0,
),
Icon(
Icons.arrow_right,
size: 70.0,
),
Text('Next'),
],
),
)
],
),
),
),
);
}
}
use - for previous and + for next
var kamiz=['פָּרָ','חָםָ','נָבָּ','עָוָ','אָםָ','מָרָ','כָּכָּ','מָמָ','פָּפָּ','בָּרָ','קָרָ','דָּרָ','וָרָ','הָרָ','תָּרָ','בָּם','כָּלָ','כָּר','שָׁלָ','סָרָ','כָּכָּ','אָםָ','חָםָ','אָל','כָּלָ'];
int index = 0;
int prev = kamiz[index-1];
int next = kamiz[index+1];
Make sure to check bounds.

How to write function for call button in calling app in flutter?

I have a text field in which user enters a number and a Raisedbutton.By clicking that button user should be able to make call on that number . How to write onPressed() function for that buton??
Above this code I have my main class in which Home() class is getting called
import 'package:flutter/material.dart';
class Home extends StatefulWidget{
#override
State<StatefulWidget> createState() {
return HomeState();
}
}
class HomeState extends State<Home> {
TextEditingController numcontroller = new TextEditingController();
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.deepPurple,
title: Text('Calling App'),
),
body: Column(
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 60.0, left: 10.0, right: 10.0),
child: TextField(
controller: numcontroller,
decoration: InputDecoration(
labelText: 'Enter Phone Number',
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.deepPurple,
)
)
)
),
),
Container(
height: 45.0,
width: 90.0,
margin: EdgeInsets.only(top: 40, left: 10, right: 10.0),
child: RaisedButton(
color: Colors.deepPurple,
elevation: 7.0,
child: Text(
'Call',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
),
),
onPressed: () {
_calling();
}
),
)
],
),
),
);
}
void _calling(){
}
}
suppose I have entered a number 94********.then on pressing that button the call should be connected to this number .If busy or switch off then should show any alert message.
First import the URL launcher dependency
url_launcher: ^5.2.5
Then your calling function should look like this
_calling() async {
const url = 'tel:+12345678';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
if you want to make actually a phone call from the application then you need CALL_PHONE permission that is marked as a sensitive permission and your app will not be compatible with google play policy.
you can open the phone app instead,
first install url_launcher
in pubspec.yaml
dependencies:
url_launcher: ^5.0.3
then
void _calling(){
_launchURL(numcontroller.text);
}
_launchURL(String phone) async {
const url = 'tel:$phone';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}