offline_zen_stories 0.0.321
offline_zen_stories: ^0.0.321 copied to clipboard
A Flutter package that provides calming Zen stories when offline.
Offline Zen Stories #
A Flutter package that provides randomized calming short stories or motivational quotes when the app detects no internet connection. Turn frustrating offline moments into peaceful, uplifting ones.
Features #
- Offline Stories & Quotes: A collection of inspiring and calming stories to reduce stress.
- Network Detection: Automatically detects when the device goes offline.
- Beautiful UI: Display story cards with smooth animations using Lottie.
- Simple Integration: Easy to add to any Flutter app.
Installation #
-
Add the package to your
pubspec.yaml:dependencies: offline_zen_stories: git: https://github.com/Suneel-DK/Offline-Zen-Stories -
Run
flutter pub getto fetch the package. -
Ensure you add the required
connectivity_plusandlottiedependencies:dependencies: connectivity_plus: ^4.0.1 lottie: ^2.2.0 -
Add your custom Lottie animation file if needed in the
assets/directory.
Usage #
Basic Example #
import 'package:flutter/material.dart';
import 'package:offline_zen_stories/zen_helper.dart';
import 'package:offline_zen_stories/zen_story_card.dart';
void main() => runApp(ZenApp());
class ZenApp extends StatefulWidget {
@override
_ZenAppState createState() => _ZenAppState();
}
class _ZenAppState extends State<ZenApp> {
final ZenHelper _zenHelper = ZenHelper();
String _story = "Check your internet to get calm vibes.";
@override
void initState() {
super.initState();
checkOfflineMode();
}
Future<void> checkOfflineMode() async {
if (await _zenHelper.isOffline()) {
setState(() {
_story = _zenHelper.getRandomZenStory();
});
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text("Offline Zen Stories")),
body: Center(child: ZenStoryCard(text: _story)),
),
);
}
}
API Reference #
ZenHelper #
Future<bool> isOffline()— Checks whether the device is currently offline.String getRandomZenStory()— Returns a random Zen story.String getRandomQuote()— Returns a random motivational quote.
ZenStoryCard #
- A widget to display beautiful animated story cards.
- Constructor:
ZenStoryCard({required String text})
Customization #
- Replace or extend the story and quote collections in
zen_stories_data.dart. - Use your custom Lottie animation by replacing
meditation.json.
License #
MIT License