Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] android – Flutter Flatbutton onpressed not working while trying to open phone dialer

Posted on November 14, 2022

Solution 1 :

Did you try putting the print before launch? It could be that launch is getting stuck and then the print never gets reached (this has happened to me with certain packages).

I am not sure how launch works with phone numbers but you may want to look into if youre using it properly.

Solution 2 :

I’m ok with this code.

launch('tel:$yourPhoneNo');

Problem :

Hello new to flutter here. I am trying to open phone dialer with a predefined phone number after pressing Call button that is Flatbutton inside Positioned, but it is not working and does not show any error either. I tried printing some values on onpressed as well but it did not print any. I have called this widget in another dart file.

Here i am using url_launcher package to launch the phone dialog.
If any other alternative way please help.

(Removed some unimportant design codes below)

class CallCard extends StatefulWidget {
  @override
  _CallCardState createState() => _CallCardState();
}

class _CallCardState extends State<CallCard> {
  @override
  Widget build(BuildContext context) {
        return Positioned(
        bottom: -170,
        child: Container(
          child: Column(
            children: <Widget>[
              SizedBox(
                height: 15,
              ),
              Text(
                'Are you feeling well today?',
                style: TextStyle(
                  fontSize: 24.0,
                ),
              ),

              Text(
                'Give us a call or visit our website.',
                style: TextStyle(
                  fontSize: 18.0,
                  fontWeight: FontWeight.w300,
                ),
              ),
              SizedBox(
                height: 23.0,
              ),
              Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: <Widget>[
                  FlatButton(
                    padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),
                    color: Color(0xff9ce47c),
                    onPressed: () {
                      final String phone = "01-4441577";
                      launch(phone);
                      print('here');
                    },
                    shape: RoundedRectangleBorder(
                      side: BorderSide(color: Colors.black),
                      borderRadius: BorderRadius.circular(50),
                    ),
                    child: Row(
                      children: <Widget>[
                        Icon(
                          LineAwesomeIcons.phone,
                          size: 22,
                        ),
                        SizedBox(
                          width: 5.0,
                        ),
                        Text(
                          'Call Now',
                          style: TextStyle(
                            fontSize: 16,
                          ),
                        ),
                      ],
                    ),
                  ),
                  SizedBox(
                    width: 1.0,
                  ),
                  
                      ],
                    ),
                  ),
                ],
              )
            ],
          ),
          
        ));
  }
}

This is the code where I have called this widget (inside Stack)

child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Stack(
              alignment: Alignment.topCenter,
              overflow: Overflow.visible,
              children: <Widget>[
                _backgroundCover(),
                //content inside header
                Positioned(
                  top: 80,
                  left: 30,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                    //crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Text(
                        'Hello User',
                        style: TextStyle(
                          fontSize: 36,
                          fontWeight: FontWeight.w500,
                          color: Colors.black,
                        ),
                      ),
                      SizedBox(width: 10.0,),
                      // Padding(padding: EdgeInsets.only(right: 200.0)),
                      IconButton(
                          icon: Icon(
                            LineAwesomeIcons.power_off,
                            size: 40.0,
                          ),
                          onPressed: () {
                            DialogHelper.exit(context);
                            // await _auth.signOut();
                          }),
                    ],
                  ),
                ),
                CallCard(),
                
              ],
            ),
          ],
        ),
      ),
    );

Comments

Comment posted by void

Can you add a code of the

READ  [ANSWERED] I am gettin an error when try to generate android or ios build of ionic project
Powered by Inline Related Posts

Comment posted by Mr Bond

i added it, (CallCard())

Comment posted by void

Kindly add the code snippet of the Stack to your question so I can help. @Mr Bond

Comment posted by Mr Bond

Hey @TimilehinJegede thanks for your comment, I solved it by simply removing it from the Stack widget. Thanks tho 🙂

Comment posted by Candace

also one more thing, what are your intentions with positioned? is Stack an ancestor?

Comment posted by Mr Bond

yes Stack is an parent, i dont know someone told me to use Positioned so i did

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress