dynamic_storage_directory 1.0.0 dynamic_storage_directory: ^1.0.0 copied to clipboard
A Flutter package that provides a clean way to handle storage directory path on both web and non-web platforms and debug and release builds.
import 'package:flutter/material.dart';
import 'package:dynamic_storage_directory/dynamic_storage_directory.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:path_provider/path_provider.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize Hydrated Bloc Storage dynamically.
HydratedBloc.storage = await HydratedStorage.build(
storageDirectory: await getStorageDirectory(
webStorageDirectory: HydratedStorage
.webStorageDirectory, // web storage directory specified by hydrated_bloc
releaseStorageDirectory:
getApplicationSupportDirectory(), // release storage directory specified by developer
),
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Placeholder(),
),
);
}
}