flutter url 사용방법(이메일, 전화하기!)
2022. 11. 30. 16:38ㆍ개발 공부/Flutter
시작전에 공지! 에뮬레이터로는 안될때가 있어서 폰에 연결해서 해보세요!
에뮬레이터 : 다른 프로그램이나 장치를 모방하는 "컴퓨터 프로그램 또는 전자기기의 능력"
ㄴ 한마디로 실제 폰 말고 저희 안드로이드 스튜디오 같은곳에 있는 가짜폰(진짜로 갖고싶긴하지만~)
ex) 이메일@000.com 이라는 텍스트를 클릭하였을때 이메일을 보내게 하고싶다면 이렇게 하면됩니다.
Container(
margin: const EdgeInsets.only(left: 45),
child: TextButton(
onPressed: () async {
const url = 'mailto:이메일@000.com';
if (await launchUrl(Uri.parse(url))) {
await canLaunchUrl(Uri.parse(url));
} else {
throw 'Could not launch $url';
}
},
child: const Text('이메일@000.com', style: TextStyle(color: Colors.white),)
)
),
결과
ex) 나는 텍스트말고 아이콘 클릭했을때 할랭~
전화기 모양 아이콘 눌러서 전화하게 해야지
final tel = Uri.parse('tel:01012345678');
IconButton(
onPressed: () async {await launchUrl(tel);},
icon: const Icon(Icons.phone)
)
결과
'개발 공부 > Flutter' 카테고리의 다른 글
flutter TextEditingController 삼항연산자 (0) | 2022.12.21 |
---|---|
failed to read PNG signature: file does not start with PNG signature.(파일 확장자 에러) (0) | 2022.12.01 |