A flutter boilerplate project with GetX state management.

Last update: Jun 30, 2022

flutter_getx_boilerplate

Languages: English (this file), Chinese.

Introduction

During my study of Flutter, I have been using the flutter_bloc state management framework. I accidentally saw the GetX state management framework. Through ReadMe, I found that the GetX framework is very easy to get started. So I want to write a GetX Starter project while learning, which can not only help myself Learning can also help others quickly build a boilerplate. Before building this boilerplate, I searched many similar projects, and found that they were relatively simple, and none of them covered the common things that the project should have, so I sprouted the idea of ​​writing one by myself. Let me introduce them one by one below.

Technology & Project Introduction

Use Flutter 2.x to build a set of features containing predefined folder structure, style themes, API access, state management, routing & dependencies, etc. The project structure is clear and can be easily used as a Flutter template project. Technologies used include but are not limited to Flutter, Dart, GetX, etc.

Installation & Use

Step 1:

Fork this project to your own warehouse:

git clone https://github.com/KevinZhang19870314/flutter_getx_boilerplate.git

Step 2:

Open the project folder with VS Code and execute the following command to install the dependency package:

flutter pub get

Step 3:

Open the main.dart file in the lib folder, F5 or Ctrl + F5 to run the project, and then you can start developing and debugging.

Folder structure

The following is the project folder structure (only the folders under lib are introduced)

lib/
|- api - Global Restful api requests, including interceptors, etc.
   |- interceptors - Interceptors, including auth, request, and response interceptors.
   |- api.dart - Restful api export file.
|- lang - Internationalization, including translation files, translation service files, etc.
   |- lang.dart - Language export file.
|- models - Various structured entity classes, divided into request and response entities.
   |- models.dart - Entity class export file.
|- modules - Business module folder.
   |- auth - Login & Registration Module.
   |- home - Home module.
   |- splash - Splash module.
   |- modules.dart - Module export file.
|- routes - Routing module.
   |- app_pages.dart - Routing page configuration.
   |- app_routes.dart - Route names.
   |- routes.dart - Route export file.
|- Shared - Global shared folders, including static variables, global services, utils, global Widgets, etc.
   |- shared.dart - Global shared export file.
|- theme - Theme folder.
|- app_bindings.dart - Services started before the app runs, such as Restful api.
|- di.dart - Global dependency injection objects, such as SharedPreferences, etc.
|- main.dart - Main entry.

Other

In the writing process, because it involves the call of Restful api, here I used the free test api provided by REQ|RES.

Test User as below:

email: "[email protected]",
password: "pistol"

GitHub

https://github.com/KevinZhang19870314/flutter_getx_boilerplate
You might also like...

Example of use bloc + freezed with a state that contains a list

blocfreezedlistexample A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you s

Mar 21, 2022

Timer based on provider state manager

timer_provider Timer based on provider state manager Getting Started This project is a starting point for a Flutter application. A few resources to ge

Nov 6, 2021

Trip management mobile Application

Trip management mobile Application

HereYouGO Trip management mobile Application This app will help you Track your expense during your trips. Track your trip destinations and the sub tri

Apr 12, 2022

Functional programming in Dart and Flutter. All the main functional programming types and patterns fully documented, tested, and with examples.

Fpdart Functional programming in Dart and Flutter. All the main functional programming types and patterns fully documented, tested, and with examples.

Jun 24, 2022

A basic boilerplate template for starting a Flutter GetX project. GetX, Dio, MVVM, get CLI, Localization, Pagination etc are implemented.

A basic boilerplate template for starting a Flutter GetX project. GetX, Dio, MVVM, get CLI, Localization, Pagination etc are implemented.

Flutter GetX Template (GetX, Dio, MVVM) This Flutter Template using GetX package for State management, routing and Dependency Injection (bindings). We

Jun 23, 2022

Flutter getx template - A Flutter Template using GetX package for State management, routing and Dependency Injection

Flutter getx template - A Flutter Template using GetX package for State management, routing and Dependency Injection

Flutter GetX Template (GetX, Dio, MVVM) This Flutter Template using GetX package

May 9, 2022

Flutter boilerplate - A boilerplate project created in flutter using MobX and Provider

Boilerplate Project A boilerplate project created in flutter using MobX and Prov

Jan 22, 2022

Building a simple Flutter app for practicing and understanding the GetX State Management and Route Management.

GetX State Management Demo with full understanding of State Management (with GetBuiler, GetX, Obx), Route Management and SnackBar.

May 19, 2022

GetX demo Counter with full understanding of State Management, Route Management and SnackBar

GetX demo Counter with full understanding of State Management, Route Management and SnackBar

Apr 4, 2022

Flutter boilerplate: support Android, iOS, Web, Mac, Linux, Window with bloc(cubit) state management

Flutter boilerplate: support Android, iOS, Web, Mac, Linux, Window with bloc(cubit) state management, dynamic theme, localization, environment (.env), logger, navigation (go_router), responsiveness (mobile, tablet, desktop), lint, unit/widget/integration test and more ...

Jun 9, 2022

The Movie DB App with Flutter GetX State Management

The Movie DB App with Flutter GetX State Management

The Movie DB App with Flutter GetX A new Flutter TheMovieDB Application example with GetX State Management Register and get Api Key from The Movie DB

Jun 23, 2022

Flutter shopping app with Getx for State management, Dio for APIs and Hive for the local database.

Flutter shopping app with Getx for State management, Dio for APIs and Hive for the local database.

Created By Sajjad Javadi Email: [email protected] Show some ❀️ and star the repo to support the project Flutter Shopping app example In this pr

Mar 28, 2022

Flutter Task Manager Application Using GetX State Management

Flutter Task Manager Application Using GetX State Management

Flutter Task Manager Application Using GetX State Management flutter_getx_todo A new Flutter project. Getting Started This project is a starting point

Dec 9, 2021

FlutterQRcode - Flutter QR Code Scanner app for a specific type of QR using GetX State Management Architecture

FlutterQRcode - Flutter QR Code Scanner app for a specific type of QR using GetX State Management Architecture

qrcode A new Flutter QR Scanner Project for Data Entry using GetX state manageme

Jun 8, 2022

GetX - one of the most popular state management solution in flutter

GetX - one of the most popular state management solution in flutter

GteX Tutorial - Udemy GetX is one of the most popular state management solution in flutter. In addition to state management, GetX provides easy way to

May 18, 2022

A social media application developed using Flutter and GetX state management

A social media application developed using Flutter and GetX state management

Jun 23, 2022

An example Flutter Shopping Cart UI using GetX State Management in conjunction with Firestore Database.

shopping_cart An example Flutter Shopping Cart UI using GetX State Management in conjunction with Firestore Database. πŸ“½οΈ Demo Demo.Shopping.Cart.mp4

Apr 5, 2022

FREE FLUTTER QUIZ APP WITH GETX STATE-MANAGEMENT

FREE FLUTTER QUIZ APP WITH GETX STATE-MANAGEMENT

This is free code for a flutter quiz app. all you need is just set up firebase for this project. Home

Jun 19, 2022

A new video calling mobile application using Flutter, Agora SDK and GetX state management.

A new video calling mobile application using Flutter, Agora SDK and GetX state management.

LiveBox : A Video Calling App A new video calling mobile application using Flutter, Agora SDK and GetX state management. Features Login Registration F

Jun 19, 2022
Comments
  • 1. can you help me?

    i have been custom your code

    response_interceptor.dart

    void handleErrorStatus(Response response) { switch (response.statusCode) { case 400: final message = ErrorResponse.fromJson(response.body); CommonWidget.toast(message.message); break; case 403: final message = ErrorResponse.fromJson(response.body); print(message.message); //CommonWidget.toast(message.message); Get.toNamed(Routes.VERIFY_EMAIL); break; default: }

    ============================== api_repository.dart

    Future<UserResponse?> getUser() async { final res = await apiProvider.getUser('/api/user'); if (res.statusCode == 200) { return UserResponse.fromJson(res.body); } }

    when iam run, i am get this error, in file api_repository.dart

    Exception has occurred. _CastError (type 'Null' is not a subtype of type 'Response' in type cast)

    Reviewed by hanafiahtkj at 2021-12-25 01:34
  • 2. request_interceptor error when i'm uncomment

    request_interceptor.dart

    ==============

    import 'dart:async';

    import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get_connect/http/src/request/request.dart'; import 'package:flutter_getx_boilerplate/shared/shared.dart';

    FutureOr requestInterceptor(request) async { final token = StorageService.box.pull(StorageItems.accessToken);

    request.headers['X-Requested-With'] = 'XMLHttpRequest'; request.headers['Authorization'] = 'Bearer $token';

    EasyLoading.show(status: 'loading...'); return request; }

    storage_service.dart

    import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart';

    class StorageService extends GetxService { Future init() async { return await SharedPreferences.getInstance(); } }

    can you help me please

    Reviewed by hanafiahtkj at 2021-11-29 22:39
  • 3. Changing tabs makes the view keeps refreshing.

    When we change tab, the view keeps refreshing. For ex, at the first tab, you scroll the view to bottom, then switch to another tab and then get back to the first tab. This time the view refreshes and scroll up again. It should be the same state. Please fix. Thanks.

    Reviewed by tuanbs at 2021-05-02 16:43
  • 4. Dublicate Globalkey error

    after Sign In and log off at me page. If you again try to click sign In button you get error

    Launching lib\main.dart on Chrome in debug mode... Debug service listening on ws://127.0.0.1:62522/bnQE7F-YJxU=/ws Running with sound null safety Connecting to VM Service at ws://127.0.0.1:62522/bnQE7F-YJxU=/ws [GETX] Instance "SharedPreferences" has been created [GETX] Instance "ApiProvider" has been created [GETX] Instance "ApiProvider" has been initialized [GETX] Instance "ApiRepository" has been created [GETX] Instance "GetMaterialController" has been created [GETX] Instance "GetMaterialController" has been initialized [GETX] GOING TO ROUTE / [GETX] Instance "SplashController" has been created [GETX] Instance "SplashController" has been initialized [GETX] GOING TO ROUTE /auth [GETX] Instance "AuthController" has been created [GETX] Instance "AuthController" has been initialized [GETX] GOING TO ROUTE /auth/login [GETX] GOING TO ROUTE /home [GETX] Instance "HomeController" has been created [GETX] Instance "HomeController" has been initialized [GETX] GOING TO ROUTE /auth [GETX] GOING TO ROUTE /auth/login

    ════════ Exception caught by widgets library ═══════════════════════════════════ The following assertion was thrown building Form-[LabeledGlobalKey#2aaf7](state: FormState#ba874): Assertion failed: _route == ModalRoute.of(context) is not true

    The relevant error-causing widget was Form-[LabeledGlobalKey#2aaf7] When the exception was thrown, this was the stack C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 236:49 throw_ C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3 assertFailed packages/flutter/src/widgets/will_pop_scope.dart 135:36 didUpdateWidget packages/flutter/src/widgets/framework.dart 4754:57 update packages/flutter/src/widgets/framework.dart 3345:14 updateChild ... ════════════════════════════════════════════════════════════════════════════════

    ════════ Exception caught by widgets library ═══════════════════════════════════ Duplicate GlobalKey detected in widget tree. ════════════════════════════════════════════════════════════════════════════════

    Reviewed by guyulmaz at 2021-04-13 12:20

Related

MobX for the Dart language. Hassle-free, reactive state-management for your Dart and Flutter apps.
MobX for the Dart language. Hassle-free, reactive state-management for your Dart and Flutter apps.

Language: English | PortuguΓͺs | Chinese mobx.dart MobX for the Dart language. Supercharge the state-management in your Dart apps with Transparent Func

Jun 22, 2022
Flutter MVU architecture/state management package

mvu_flutter No mutability. No builders. No connectors. No reducers. No StreamControllers and subscription management. A truly declarative state manage

Jul 29, 2021
Simple global state management for Flutter

Slices Slices is a minimalist state manegement, focused specifically for applications that needs a global state where different "pieces" of the applic

Jun 15, 2021
The modular state management solution for flutter.
The modular state management solution for flutter.

The modular state management solution for flutter. Easy debugging : each event is predictable and goes into a single pipeline Centralized state : soli

Jan 5, 2022
Flutter State Management with provider :rocket:
Flutter State Management with provider :rocket:

Flutter - Gerenciamento de Estados com Provider Objetivos ao completar os estudos Aprenda a gerenciar o estado da sua aplicação com Single Source of T

Dec 6, 2021
A predictable state management library that helps implement the BLoC design pattern
A predictable state management library that helps implement the BLoC design pattern

A predictable state management library that helps implement the BLoC design pattern. Package Pub bloc bloc_test flutter_bloc angular_bloc hydrated_blo

Jun 27, 2022
Another state management solution

VxState VxState is a state management library built for Flutter apps with focus on simplicity. It is inspired by StoreKeeper & libraries like Redux, V

Jun 20, 2022
A simple way to access state while robust and testable.
A simple way to access state while robust and testable.

A state-management library that: catches programming errors at compile time rather than at runtime removes nesting for listening/combining objects ens

Jun 29, 2022
A lightweight, yet powerful way to bind your application state with your business logic.
A lightweight, yet powerful way to bind your application state with your business logic.

binder A lightweight, yet powerful way to bind your application state with your business logic. The vision As other state management pattern, binder a

May 22, 2022
Manage the state of your widgets using imperative programming concepts.

Imperative Flutter Manage the state of your widgets using imperative programming concepts. Setup Intall imperative_flutter package in pubspec.yaml dep

Jan 9, 2022