Hello guys today, Im going to tell you about the function below
This function uses the library called 'share' and you can get it in
https://pub.dev/packages/share#-readme-tab-
after you come here
attach
dependencies:
share: ^0.6.4
at yami file
& attach
import 'package:share/share.dart';
at your dart file
so now, you are ready to use it.
Here are my codes below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
import 'package:flutter/material.dart';
import 'package:launch_review/launch_review.dart';
import 'package:share/share.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: '아몰라',
theme: ThemeData(
primaryColor: Colors.white,
),
home: BottomSheet(),
);
}
}
class BottomSheet extends StatefulWidget {
@override
_BottomSheetState createState() => _BottomSheetState();
}
class _BottomSheetState extends State<BottomSheet> {
String _selectedItem = '';
// share(공유) 기능을 통해 메일 앱에 들어갈 내용 텍스트. 문의메일주소를 제공함으로써 문의를 쉽게 하도록 도와줌.
final String _text_email = '\n\n\n문의메일주소: help@sothecode.com';
final String _text_subject = '니니네네 어플의 문의사항입니다.';
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Text('Show'),
onPressed: () => _onButtonPressed(),
),
Text(
_selectedItem,
style: TextStyle(fontSize: 30),
),
],
),
),
);
}
void _onButtonPressed() {
showModalBottomSheet(
context: context,
builder: (context) {
return Container(
color: Color(0xFF737373),
height: 180,
child: Container(
child: _buildBottomNavigationMenu(),
decoration: BoxDecoration(
color: Theme.of(context).canvasColor,
borderRadius: BorderRadius.only(
topLeft: const Radius.circular(10),
topRight: const Radius.circular(10),
),
),
)
);
});
}
Column _buildBottomNavigationMenu() {
return Column(
children: <Widget>[
ListTile(
title: Text('스토어 평가하기'),
onTap: () => LaunchReview.launch(
androidAppId: "net.nrise.wippy",
),
),
Container(
height: 1.5,
color: Color.fromRGBO(210, 210, 210, 99),
),
ListTile(
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('버전'),
Text('v.1.5.0'),
],
),
),
Container(
height: 1.5,
color: Color.fromRGBO(210, 210, 210, 99),
),
ListTile(
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('서비스 문의'),
Text('help@sothecode.com'),
],
),
onTap: () {
Share.share(
_text_email,
subject: _text_subject,
);},
),
],
);
}
}
|
cs |
I usually gives you the whole code first because, for the beginner its not easy to use codes part by part while they dont know the location of each part.
From line no.29, no.30, I made final text that I want to share through other apps
From line no.107 ~ to line no.111, I put Function Share.share() in onTap: () {} so that when I touch the button, I can share thext through other apps.
so please ignore the other parts, and try this code.
It is easy to use.
Thank you for reading this post. byebye-!
'안드로이드 > Flutter' 카테고리의 다른 글
How to make a right size of Widgets in Flutter (0) | 2020.05.06 |
---|---|
pub.dev에서 라이브러리를 가져오는방법 (0) | 2020.04.28 |
플러터 위젯 - 화면 표시용 위젯 (0) | 2020.04.23 |
How can I use Future in Flutter(Dart) (0) | 2020.04.22 |
플러터 캘린더를 한국어로 바꾸는 방법 (1) | 2020.04.20 |