A modern blog application built with Flutter, powered by Supabase for a robust backend, and designed for a smooth user experience.
- User Authentication: Secure sign-up and sign-in processes (Email & Password).
- Blog Creation: Authenticated users can create and publish their own blog posts.
- Blog Viewing: Browse and read blog posts with detailed views.
- Image Handling: Displays images associated with blog posts, including loading and error placeholders for a better user experience.
- Reading Time Calculation: Automatically estimates the reading time for articles.
- Date Formatting: Presents blog post dates in a user-friendly format.
- Responsive UI: Designed to adapt layouts smoothly across various screen sizes.
- Dark Mode Support: Adapts to system theme preferences, ensuring a comfortable viewing experience in low light.
- Local Data Storage (Hive): Leverages Hive for efficient local data persistence, potentially enabling offline capabilities or caching.
- Flutter: The UI toolkit for building natively compiled applications from a single codebase.
- Supabase:
- Authentication: Manages user registration and login.
- PostgreSQL Database: Stores all application data, including blog posts and user profiles.
- Row Level Security (RLS): Secures database access, ensuring data privacy and integrity.
- Storage: Hosts images for blog posts.
- Bloc: A popular state management library for Flutter, facilitating predictable and testable application logic.
- Hive: A fast, lightweight, and local key-value database for efficient offline data management or caching.
- Firebase (Potential): While primarily Supabase-driven, the project structure suggests potential integration for services like analytics or crash reporting.
path_provider: A Flutter plugin used to find common locations on the device file system, crucial for Hive initialization.
-
Clone the repository:
git clone [https://github.com/yourusername/blog_app.git](https://github.com/yourusername/blog_app.git) cd blog_app -
Install Flutter dependencies:
flutter pub get
-
Supabase Setup:
- Create a new project on Supabase.
- Database: Create a
blogstable with essential columns (e.g.,id(UUID, PK),title,content,image_url,poster_id(UUID, FK toauth.users),topics(text array),updated_at(timestamp)). - Row Level Security (RLS):
- Enable RLS for the
blogstable. - Add an
INSERTpolicy (e.g., named "Allow authenticated user to create own blogs") withTarget roles: authenticatedand theWITH CHECKexpression:auth.uid() = poster_id. This ensures users can only create their own posts.
- Enable RLS for the
- API Keys: Obtain your project's
anon(public) key andURLfrom your Supabase Project Settings > API.
-
Configure Supabase in Flutter:
- Open
lib/main.dart. - Initialize Supabase with your project's URL and
anonkey. - Note: For production, consider using environment variables to manage sensitive keys securely.
- Open
-
Android Configuration:
- Navigate to
android/app/build.gradle. - Set the
minSdkVersionto23within thedefaultConfigblock to ensure compatibility with all dependencies, includingisar_flutter_libs:defaultConfig { // ... minSdk = 23 // ... }
- Navigate to
-
Run the application:
flutter run
(Ensure an Android emulator or physical device is connected, or choose a web/desktop target.)
AppBar/CupertinoNavigationBarTransparency:AppBar(Material): Background transparency is achieved viaAppBarThemeinThemeData.CupertinoNavigationBar: ItsbackgroundColoris set directly on the widget instance, often conditionally based onMediaQuery.of(context).platformBrightnessfor dynamic dark mode support.
- Cupertino Back Button: To display the iOS-style caret back button across the app, ensure all route navigations utilize
CupertinoPageRoute. cupertinoOverrideTheme: Used withinThemeDatato apply global Cupertino styling (e.g.,brightness,primaryColor,textTheme) to Cupertino widgets when they are embedded within aMaterialAppstructure.
lib/
├── core/
│ ├── common/
│ ├── errors/
│ ├── usecase/
│ └── theme/
│ └── secrets/
├── features/
│ ├── auth/
│ │ ├── data/
│ │ ├── domain/
│ │ └── presentation/
│ └── blog/
│ ├── data/
│ ├── domain/
│ └── presentation/
└── main.dart
Feel free to fork the repository, open issues, or submit pull requests. All contributions are welcome!
