import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:screenshot/screenshot.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const MaterialApp( home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({ Key? key, }) : super(key: key); @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { ScreenshotController screenshotController = ScreenshotController(); void _captureAndShow() async { screenshotController .capture(delay: Duration(milliseconds: 10)) .then((capturedImage) async { ShowCapturedWidget(context, capturedImage!); }).catchError((onError) { print(onError); }); } Future ShowCapturedWidget( BuildContext context, Uint8List capturedImage) { return showDialog( useSafeArea: false, context: context, builder: (context) => Scaffold( appBar: AppBar( title: const Text("Capture widget screenshot"), ), body: Center( child: capturedImage != null ? Image.memory(capturedImage) : Container()), ), ); } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Screenshot(controller: screenshotController, child: myWidget()), ), floatingActionButton: FloatingActionButton( onPressed: _captureAndShow, tooltip: 'Capture an image of myWidget() and show it in a dialog', child: const Icon(Icons.add), ), ); } } Widget myWidget() { return Stack( alignment: Alignment.center, children: [ SizedBox( width: 400, height: 230, child: ClipRRect( borderRadius: BorderRadius.circular(36.0), child: Container( decoration: const BoxDecoration( color: Colors.green, ), ), ), ), // outline label SizedBox( width: 370, height: 200, child: ClipRRect( borderRadius: BorderRadius.circular(25.0), child: Container( decoration: const BoxDecoration( color: Colors.white, ), ), ), ), SizedBox( width: 340, height: 200, child: Column( children: [ const Text('my label'), //Image.asset('images/logo.png'), Container( height: 100.0, width: 100.0, decoration: const BoxDecoration( image: DecorationImage( image: NetworkImage('https://picsum.photos/250?image=11'), fit: BoxFit.fill, ), shape: BoxShape.circle, ), ), ], ), ), ], ); }