// Automatic FlutterFlow imports
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/custom_code/actions/index.dart'; // Imports custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'dart:io';
import 'package:path_provider/path_provider.dart';
import 'package:screenshot/screenshot.dart';
import 'package:share_plus/share_plus.dart';
import 'package:http/http.dart' as http;
class ShareScreenShot extends StatefulWidget {
const ShareScreenShot({
Key? key,
this.width,
this.height,
required this.workout,
required this.imagen,
}) : super(key: key);
final double? width;
final double? height;
final String workout;
final String imagen;
@override
_ShareScreenShotState createState() => _ShareScreenShotState();
}
class _ShareScreenShotState extends State<ShareScreenShot> {
final _screenshotController = ScreenshotController();
@override
Widget build(BuildContext context) {
return Container(
// Generated code for this Column Widget...
child: Screenshot(
controller: _screenshotController,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.network(
widget.imagen,
width: MediaQuery.sizeOf(context).width,
height: 500,
fit: BoxFit.contain,
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 12, 0, 0),
child: Text(
'Congrats workout completed 🏆💞',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Manrope',
fontWeight: FontWeight.w600,
),
),
),
Text(
widget.workout,
style: FlutterFlowTheme.of(context).bodyMedium,
),
TextButton(
child: Text('Take ScreenShot'),
onPressed: _takeScreenshot,
),
],
)),
);
}
void _takeScreenshot() async {
final imageFile = await _screenshotController.capture();
final temp = await getTemporaryDirectory();
final path = '${temp.path}/image.jpg';
File(path).writeAsBytesSync(imageFile!);
await Share.shareFiles([path], text: 'Hey, I just completed this workout');
}
}
FlutterFlow ile oluşturduğum içinde bir çok işlevin gerçekleştiği widget'ın nasıl ekran görüntüsünü alıp paylaşmasını sağlayabilirim (Paylaşılacak widget'a basılı tutulduğunda eylem tetiklenmelidir.)? FlutterFlow Yükseltilmiş sürüm kullanıyorum görüntüsünü paylaşmak istediğim widget'ın kodları mevcut ama yapamıyorum. LÜTFEN YARDIM EDER MİSİNİZ?
// Generated code for this Container Widget...
Align(
alignment: AlignmentDirectional(0, 0),
child: Container(
width: MediaQuery.sizeOf(context).width * 0.75,
height: MediaQuery.sizeOf(context).height * 0.65,
constraints: BoxConstraints(
maxWidth: 400,
maxHeight: 600,
),
decoration: BoxDecoration(
color: valueOrDefault<Color>(
_model.gonderiArkaPlanRengi,
FlutterFlowTheme.of(context).alternate,
),
borderRadius: BorderRadius.circular(18),
border: Border.all(
color: valueOrDefault<Color>(
_model.arkaPlanRengi,
FlutterFlowTheme.of(context).primaryBackground,
),
),
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(15, 15, 15, 15),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 3),
child: FutureBuilder<UsersRecord>(
future:
UsersRecord.getDocumentOnce(widget.gonderi!.paylasanKisi!),
builder: (context, snapshot) {
// Customize what your widget looks like when it's loading.
if (!snapshot.hasData) {
return Center(
child: SizedBox(
width: 31,
height: 31,
child: SpinKitThreeBounce(
color: FlutterFlowTheme.of(context).error,
size: 31,
),
),
);
}
final rowUsersRecord = snapshot.data!;
return Row(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width: 43,
height: 43,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
shape: BoxShape.circle,
),
child: CachedNetworkImage(
fadeInDuration: Duration(milliseconds: 500),
fadeOutDuration: Duration(milliseconds: 500),
imageUrl: rowUsersRecord.fotograflar.first,
fit: BoxFit.cover,
errorWidget: (context, error, stackTrace) =>
Image.asset(
'assets/images/error_image.png',
fit: BoxFit.cover,
),
),
),
Expanded(
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(10, 0, 10, 0),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
rowUsersRecord.displayName,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: FlutterFlowTheme.of(context)
.bodyMediumFamily,
fontSize: 17,
fontWeight: FontWeight.w500,
useGoogleFonts: GoogleFonts.asMap()
.containsKey(
FlutterFlowTheme.of(context)
.bodyMediumFamily),
),
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0, 3, 0, 0),
child: Text(
dateTimeFormat(
'd/M/y',
widget.gonderi!.paylasimSaati!,
locale: FFLocalizations.of(context)
.languageCode,
),
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Lora',
color: FlutterFlowTheme.of(context)
.secondaryText,
fontSize: 14,
fontWeight: FontWeight.w300,
useGoogleFonts: GoogleFonts.asMap()
.containsKey('Lora'),
),
),
),
],
),
),
),
ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.asset(
'assets/images/KRAT_LOGO_SON_AIK_BEYAZ.png',
width: 41,
height: 41,
fit: BoxFit.cover,
),
),
],
);
},
),
),
Divider(
thickness: 1,
indent: 7,
endIndent: 7,
color: valueOrDefault<Color>(
_model.arkaPlanRengi,
FlutterFlowTheme.of(context).primaryBackground,
),
),
Expanded(
child: Stack(
children: [
Align(
alignment: AlignmentDirectional(1, 1),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(15, 15, 0, 15),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
if (widget.gonderi?.hasKonum() ?? true)
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0, 0, 15, 0),
child: Icon(
Icons.location_on_sharp,
color:
FlutterFlowTheme.of(context).secondaryText,
size: 30,
),
),
if (widget.gonderi?.hasGonderiSesi() ?? true)
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0, 0, 15, 0),
child: FaIcon(
FontAwesomeIcons.microphoneAlt,
color:
FlutterFlowTheme.of(context).secondaryText,
size: 30,
),
),
if (widget.gonderi?.pdf != null &&
widget.gonderi?.pdf != '')
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0, 0, 15, 0),
child: FaIcon(
FontAwesomeIcons.solidFilePdf,
color:
FlutterFlowTheme.of(context).secondaryText,
size: 30,
),
),
if (widget.gonderi?.hasPaylasimVideosu() ?? true)
FaIcon(
FontAwesomeIcons.video,
color: FlutterFlowTheme.of(context).secondaryText,
size: 30,
),
],
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 3, 0, 0),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: AlignmentDirectional(-1, -1),
child: wrapWithModel(
model: _model.textModel,
updateCallback: () => setState(() {}),
updateOnChange: true,
child: TextWidget(
yazi: widget.gonderi!.paylasimYazisi,
),
),
),
],
),
),
),
],
),
),
if (widget.gonderi!.paylasimFotograflari.length >= 1)
ClipRRect(
borderRadius: BorderRadius.circular(18),
child: OctoImage(
placeholderBuilder: (_) => SizedBox.expand(
child: Image(
image: BlurHashImage(
'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/zafer-rqs8we/assets/mbpn8y0csys0/K%C3%BCr%C5%9Fat_Logo.png'),
fit: BoxFit.cover,
),
),
image: CachedNetworkImageProvider(
widget.gonderi!.paylasimFotograflari.first,
),
width: double.infinity,
height: 200,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) => Image.asset(
'assets/images/error_image.png',
width: double.infinity,
height: 200,
fit: BoxFit.cover,
),
),
),
],
),
),
),
)