Introduction
FlutterSeed is a revolutionary tool that simplifies the process of scaffolding a Flutter app. With its visual graph builder, you can create a production-ready Flutter project in minutes. In this tutorial, we will explore how to use FlutterSeed to scaffold a Flutter app with Riverpod and go_router. We will walk through the step-by-step process of setting up a new Flutter project with FlutterSeed and configuring it to use Riverpod and go_router.
What is FlutterSeed?
FlutterSeed is a Node-based visual graph builder that exports a production-ready Flutter project ZIP. It allows you to make graph-driven decisions about your app's architecture, state, routing, backend, and theme. With its deterministic generation, you can create a new Flutter project in minutes. FlutterSeed also offers a range of features, including preset and custom flows, curated or pub.dev custom package nodes, and a CLI.
Key features of FlutterSeed include:
Graph-driven decisions: architecture, state, routing, backend, theme as visual nodes
Deterministic generation: Graph to ScaffoldConfig to ZIP
Preset + custom flow: curated or pub.dev custom package nodes
CLI: npm install -g flutterseed-cli, then flutterseed init my_app
Templates: Feature-first, E-commerce, Offline-first, Auth-only, Supabase full-stack
Setting Up FlutterSeed
To get started with FlutterSeed, you need to install the FlutterSeed CLI. You can do this by running the following command in your terminal:
bash
npm install -g flutterseed-cli
Once you have installed the FlutterSeed CLI, you can initialize a new Flutter project by running the following command:
bash
flutterseed init my_app
This will create a new Flutter project with a basic directory structure and configuration files.
Configuring Riverpod and go_router
To configure Riverpod and go_router in your Flutter project, you need to add the necessary dependencies to your pubspec.yaml file. You can do this by adding the following lines to your pubspec.yaml file:
yml
dependencies:
flutter:
sdk: flutter
riverpod: ^2.0.0
go_router: ^4.0.0
Once you have added the dependencies, you can run the following command to get the dependencies:
bash
flutter pub get
Creating a Riverpod Provider
To create a Riverpod provider, you need to create a new file that will hold your provider. For example, you can create a file called user_provider.dart. In this file, you can define your provider as follows:
dart
import 'package:riverpod/riverpod.dart';
final userProvider = Provider((ref) => User());
Creating a go_router Route
To create a go_router route, you need to define a new route in your main.dart file. For example, you can define a new route as follows:
dart
import 'package:go_router/go_router.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(),
routerConfig: GoRouter(
routes: [
GoRoute(
path: '/',
builder: (context, state) => MyHomePage(),
),
],
),
);
}
}
Conclusion
In this tutorial, we have explored how to use FlutterSeed to scaffold a Flutter app with Riverpod and go_router. We have walked through the step-by-step process of setting up a new Flutter project with FlutterSeed and configuring it to use Riverpod and go_router. With FlutterSeed, you can create a production-ready Flutter project in minutes. To learn more about FlutterSeed and its features, you can visit the official website at https://flutterseed.pro.bd.
If you are looking to simplify the process of scaffolding a Flutter app, FlutterSeed is the perfect tool for you. With its visual graph builder and range of features, you can create a new Flutter project in minutes. Try FlutterSeed today and see how it can help you streamline your Flutter development process.
Originally posted from FlutterSeed
Top comments (0)