From 3e65cca2e38052349ad2e32578edb826c31d1a2f Mon Sep 17 00:00:00 2001 From: avinashmandalapu1717-ship-it Date: Fri, 4 Sep 2026 19:19:32 +0530 Subject: [PATCH 1/2] Update installing-packages.rst --- source/tutorials/installing-packages.rst | 74 +++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/source/tutorials/installing-packages.rst b/source/tutorials/installing-packages.rst index 4c9b95030..3fa14850b 100644 --- a/source/tutorials/installing-packages.rst +++ b/source/tutorials/installing-packages.rst @@ -1,4 +1,76 @@ -.. _installing-packages: +..import 'dart:async'; +import 'dart:io'; +import 'dart:math'; + +/// A CLI implementation of the logic previously described in the Python script. +/// Since the original Python code relied on OpenCV and Tkinter (GUI), +/// this Dart CLI version provides a robust, idiomatic alternative for +/// managing ephemeral data handling logic in a console environment. + +class EphemeralManager { + final String _tempStoragePath = 'temp_snap.jpg'; + + /// Simulates capturing a snapshot. + /// In a CLI environment, we create a dummy file. + Future captureSnap() async { + try { + print('Capturing snapshot...'); + await File(_tempStoragePath).writeAsString('IMAGE_DATA_CONTENT'); + print('Snapshot saved successfully.'); + } catch (e) { + throw Exception('Failed to capture snapshot: $e'); + } + } + + /// Displays the "snap" and deletes it after the duration. + Future showEphemeral(int duration) async { + if (!await File(_tempStoragePath).exists()) { + print('No snapshot found to display.'); + return; + } + + print('Displaying ephemeral snap for $duration seconds...'); + + for (int i = duration; i > 0; i--) { + print('Viewing... $i seconds remaining.'); + await Future.delayed(const Duration(seconds: 1)); + } + + await _cleanup(); + } + + Future _cleanup() async { + final file = File(_tempStoragePath); + if (await file.exists()) { + await file.delete(); + print('Snap expired and deleted.'); + } + } +} + +Future main() async { + final manager = EphemeralManager(); + + print('--- Simple Ephemeral Snap CLI ---'); + print('1. Capture Snap'); + print('2. Quit'); + + stdout.write('Choose an option: '); + final choice = stdin.readLineSync(); + + if (choice == '1') { + try { + await manager.captureSnap(); + await manager.showEphemeral(5); + } catch (e) { + stderr.writeln('Error occurred: $e'); + } + } else { + print('Exiting application.'); + } + + exit(0); +} _installing-packages: =================== Installing Packages From 9f9f1c9f8a08be4618c45bbac4b990a310a9c6a9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 4 Sep 2026 13:51:14 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- source/tutorials/installing-packages.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/tutorials/installing-packages.rst b/source/tutorials/installing-packages.rst index 3fa14850b..92e5c2743 100644 --- a/source/tutorials/installing-packages.rst +++ b/source/tutorials/installing-packages.rst @@ -3,14 +3,14 @@ import 'dart:io'; import 'dart:math'; /// A CLI implementation of the logic previously described in the Python script. -/// Since the original Python code relied on OpenCV and Tkinter (GUI), +/// Since the original Python code relied on OpenCV and Tkinter (GUI), /// this Dart CLI version provides a robust, idiomatic alternative for /// managing ephemeral data handling logic in a console environment. class EphemeralManager { final String _tempStoragePath = 'temp_snap.jpg'; - /// Simulates capturing a snapshot. + /// Simulates capturing a snapshot. /// In a CLI environment, we create a dummy file. Future captureSnap() async { try { @@ -30,7 +30,7 @@ class EphemeralManager { } print('Displaying ephemeral snap for $duration seconds...'); - + for (int i = duration; i > 0; i--) { print('Viewing... $i seconds remaining.'); await Future.delayed(const Duration(seconds: 1));