scroll_screenshot 0.0.1
scroll_screenshot: ^0.0.1 copied to clipboard
A new Flutter package 'scroll_screenshot' function allows you to capture a full-size screenshot, and scrolling functionality is also available to capture full screens, including those hidden at the bottom
scroll_screenshot #
A new Flutter package 'scroll_screenshot' function allows you to capture a full-size screenshot, and scrolling functionality is also available to capture full screens, including those hidden at the bottom
Installation #
- Add the latest version of package to your pubspec.yaml (and run
dart pub get
):
dependencies:
scroll_screenshot: ^0.0.1
- Import the package and use it in your Flutter App.
import 'dart:developer';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:scroll_screenshot/scroll_screenshot.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final GlobalKey _globalKey = GlobalKey();
@override
void initState() {
super.initState();
}
Future<void> _captureAndSaveScreenshot() async {
String? base64String = await ScrollScreenshot.captureAndSaveScreenshot(_globalKey);
log(base64String!);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: SingleChildScrollView(
child: RepaintBoundary(
key: _globalKey,
child: Column(
children: <Widget>[
Container(
height: 2000,
color: Colors.blue,
child: const Center(
child: Text(
'Scroll down to see more content',
style: TextStyle(color: Colors.white, fontSize: 20),
),
),
),
ElevatedButton(
onPressed: () {
WidgetsBinding.instance.addPostFrameCallback((_) {
_captureAndSaveScreenshot();
});
},
child: const Text('Take Screenshot'),
),
],
),
),
),
);
}
}