Skip to content

Commit b2003b3

Browse files
committed
optimized image sharing
1 parent 27f784c commit b2003b3

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

lib/presentation/pages/love_info_page.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,27 @@ import 'package:flutter_bloc/flutter_bloc.dart';
55
import 'package:love_calculator/injection_container.dart';
66
import 'package:love_calculator/presentation/bloc/love_info_bloc.dart';
77
import 'package:love_calculator/presentation/widgets/love_info_form.dart';
8+
import 'package:share_plus/share_plus.dart';
89

910
class LoveInfoPage extends StatelessWidget {
1011
const LoveInfoPage({super.key});
1112

13+
void shareApp()async{
14+
String releaseUrl = "https://github.com/Saffron-codes/love_calculator_app/releases";
15+
await Share.share('Calculate your love percentage \nGet this app 🚀 \n$releaseUrl');
16+
}
1217
@override
1318
Widget build(BuildContext context) {
1419
return Scaffold(
1520
appBar: AppBar(
1621
title: Text('Love Calculator'),
22+
actions: [
23+
IconButton(
24+
onPressed: ()=>shareApp(),
25+
tooltip: "Share App",
26+
icon: const Icon(Icons.share),
27+
)
28+
],
1729
),
1830
body: BlocProvider<LoveInfoBloc>(
1931
create: (_) => sl<LoveInfoBloc>(),
@@ -35,7 +47,9 @@ class LoveInfoBody extends StatelessWidget {
3547
// mainAxisAlignment: MainAxisAlignment.center,
3648
physics: NeverScrollableScrollPhysics(),
3749
children: [
38-
SizedBox(height: MediaQuery.of(context).size.height*0.24,),
50+
SizedBox(
51+
height: MediaQuery.of(context).size.height * 0.24,
52+
),
3953
const LoveInfoForm(),
4054
// SizedBox(height: MediaQuery.of(context).size.height*0.9,),
4155
// Spacer(flex: 2,)

lib/presentation/widgets/love_info_form.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ class LoveInfoForm extends StatelessWidget {
2323
}
2424

2525
void takeScreenshot() async {
26+
String releaseUrl = "https://github.com/Saffron-codes/love_calculator_app/releases";
2627
screenshotController
2728
.capture(delay: Duration(seconds: 1))
2829
.then((image) async {
2930
final tempDir = await getTemporaryDirectory();
3031
final file = await File('${tempDir.path}/image.jpg').create();
3132
file.writeAsBytesSync(image!.toList());
32-
Share.shareFiles([file.path],
33-
text: '${firstNameController.text} ${secondNameController.text}');
33+
await Share.shareXFiles([XFile(file.path)],
34+
text: 'Get this app 🚀 \n$releaseUrl');
3435
});
3536
}
3637

@@ -42,7 +43,7 @@ class LoveInfoForm extends StatelessWidget {
4243
children: [
4344
TextFormField(
4445
controller: firstNameController,
45-
decoration: InputDecoration(hintText: "First Name"),
46+
decoration: const InputDecoration(hintText: "First Name"),
4647
keyboardType: TextInputType.name,
4748
validator: (value) {
4849
if (value == null || value.isEmpty) {
@@ -53,7 +54,7 @@ class LoveInfoForm extends StatelessWidget {
5354
),
5455
TextFormField(
5556
controller: secondNameController,
56-
decoration: InputDecoration(hintText: "Second Name"),
57+
decoration: const InputDecoration(hintText: "Second Name"),
5758
keyboardType: TextInputType.name,
5859
validator: (value) {
5960
if (value == null || value.isEmpty) {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A new Flutter project.
33

44
publish_to: 'none'
55

6-
version: 1.0.0+1
6+
version: 1.1.1
77

88
environment:
99
sdk: '>=2.18.6 <3.0.0'

0 commit comments

Comments
 (0)