Flutter Getx Template

Overview

Flutter Getx Template

Description:

  • This is source flutter template use getx for statemanagement

👀 Overview main.dart, After you can customize languages package, themes, pages and routes

import 'package:flutter/material.dart';
import 'package:flutter_postman_application/src/lang/translation_service.dart';
import 'package:flutter_postman_application/src/routes/app_pages.dart';
import 'package:flutter_postman_application/src/shared/logger/logger_utils.dart';
import 'package:flutter_postman_application/src/theme/theme_service.dart';
import 'package:flutter_postman_application/src/theme/themes.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';

void main() async {
  await GetStorage.init();
  runApp(GetMaterialApp(
    debugShowCheckedModeBanner: false,
    enableLog: true,
    logWriterCallback: Logger.write,
    initialRoute: AppPages.INITIAL,
    getPages: AppPages.routes,
    locale: TranslationService.locale,
    fallbackLocale: TranslationService.fallbackLocale,
    translations: TranslationService(),
    theme: Themes().lightTheme,
    darkTheme: Themes().darkTheme,
    themeMode: ThemeService().getThemeMode(),
  ));
}

🏴󠁧󠁢󠁥󠁮󠁧󠁿 Customize languages package

  • translation_service.dart
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'en_US.dart';
import 'vi_VN.dart';

class TranslationService extends Translations {
  static final locale = Get.deviceLocale;
  static final fallbackLocale = Locale('en', 'US');
  @override
  Map<String, Map<String, String>> get keys => {
        'en_US': en_US,
        'vi_VN': vi_VN,
      };
}
  • en_US.dart
const Map<String, String> en_US = {
  'helloWord': 'Hello World',
};
  • 🔥 similar to other language files

🌓 Customize theme package

  • themes.dart
import 'package:flutter/material.dart';
import 'package:flutter_postman_application/src/public/styles.dart';

class Themes {
  final lightTheme = ThemeData.light().copyWith(
    primaryColor: colorPrimary,
    appBarTheme: AppBarTheme(
      brightness: Brightness.light,
      textTheme: TextTheme(
        headline2: TextStyle(color: colorTitle),
      ),
    ),
  );
  final darkTheme = ThemeData.dark().copyWith(
    primaryColor: colorPrimary,
    appBarTheme: AppBarTheme(
      brightness: Brightness.dark,
      textTheme: TextTheme(
        headline2: TextStyle(color: mC),
      ),
    ),
  );
}

🌞 save theme mode in device storage

  • theme_service.dart
import 'package:flutter/material.dart';
import 'package:get_storage/get_storage.dart';
import 'package:get/get.dart';

class ThemeService {
  final _getStorage = GetStorage();
  final storageKey = 'isDarkMode';

  ThemeMode getThemeMode() {
    return isSavedDarkMode() ? ThemeMode.dark : ThemeMode.light;
  }

  bool isSavedDarkMode() {
    return _getStorage.read(storageKey) ?? false;
  }

  void saveThemeMode(bool isDarkMode) {
    _getStorage.write(storageKey, isDarkMode);
  }

  void changeThemeMode() {
    Get.changeThemeMode(isSavedDarkMode() ? ThemeMode.light : ThemeMode.dark);
    saveThemeMode(!isSavedDarkMode());
  }
}

Log error for dev

  • logger_utils.dart
class Logger {
  static void write(String text, {bool isError = false}) {
    Future.microtask(() => print('** $text. isError: [$isError]'));
  }
}

🔗 Management routes

  • app_routes.dart
part of 'app_pages.dart';

abstract class Routes {
  static const ROOT = '/root';
  static const HOME = '/home';
}

📂 Management pages

  • app_pages.dart
import 'package:flutter_postman_application/src/app.dart';
import 'package:get/get.dart';
part 'app_routes.dart';

// ignore: avoid_classes_with_only_static_members
class AppPages {
  static const INITIAL = Routes.ROOT;

  static final routes = [
    GetPage(
      name: Routes.ROOT,
      page: () => App(),
      children: [],
    ),
  ];
}

How I can run it?

  • 🚀 flutter version < 2.0 (1.x.x), not support null safety
  • 🚀 clone this repository
  • 🚀 run below code in terminal
flutter pub get
flutter run

Lib use in project:

get_test: ^3.13.3
get_storage: ^1.4.0

Author:

lambiengcode
You might also like...

A basic template of Flutter to get started. Includes various folders and packages that might be necessary.

A basic template of Flutter to get started. Includes various folders and packages that might be necessary.

Flutter App - Basic Template It's a time saving template with basic project structure, packages and other files like constants.dart to get started rat

Jun 12, 2022

A basic template of Flutter to get started. Includes various folders and packages that might be necessary.

A basic template of Flutter to get started. Includes various folders and packages that might be necessary.

Flutter App - Basic Template It's a time saving template with basic project structure, packages and other files like constants.dart to get started rat

Jun 12, 2022

Starting template for a new Flutter project. Using clean architecture + Riverpod.

flutter_project_template_riverpod Installation Add Flutter to your machine Open this project folder with Terminal/CMD Ensure there's no cache/build le

Dec 27, 2022

Simple Chat UI - This template is a simple chat ui build with flutter ui toolkit.

Simple Chat UI - This template is a simple chat ui build with flutter ui toolkit.

Simple Chat UI This template is a simple chat ui build with flutter ui toolkit. TODO dark mode support image support gif, video, ... web mode desktop

Apr 24, 2022

Flutter empty template to start your project.

flutter_starter Flutter empty template to help you start your project. PACKAGES Packages I've used Getx Shimmer Shared Preferences Gap Flutter Localiz

Dec 2, 2021

Flutter starter template for production applications with a REST backend

Flutter starter template for production applications with a REST backend

Flutter Boilerplate My Flutter starter template for production applications with a REST backend. The main aim of this template is to get you up and ru

Apr 13, 2022

A Meditation App UI template made using flutter and dart

A Meditation App UI template made using flutter and dart

Flutter Meditation App A Meditation App UI template made using flutter and dart. Please star the repo to support the project Screenshots Created & Mai

Dec 15, 2022

Hungry is a Free Flutter Recipe App Starter Template that can help you develop a Recipe application much faster.

Hungry is a Free Flutter Recipe App Starter Template that can help you develop a Recipe application much faster.

Hungry is a Free Flutter Recipe App Starter Template that can help you develop a Recipe application much faster. You just need to add some adjustment to the frontend and you can create your own backend.

Dec 20, 2022

Template for large or scaleable Flutter project

Template for large or scaleable Flutter project

Template Project See example usage on Youtube Config config folder contains the following folders: routes : The route folder contains all the files wh

Dec 21, 2022
Comments
  • updated README.md

    updated README.md

    Changes That I have made: 1 - Removed get_test(Couldn't able to find dependency on pubspec.yaml that's why I removed it. Please correct me if I am wrong) 2 - Upgraded get_storage as per pubspec.yaml 3 - Also updated flutter version to 2.12 as now code has been migrated to null safety. 4 - Fixed some markdown violations as per industry guidelines.

    opened by hirenvadher954 0
Owner
Dao Hong Vinh
I am a Mobile App Developer 🐼
Dao Hong Vinh
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

Hasan Abdullah 214 Jan 9, 2023
Flutter GetX Template (GetX, Dio, MVVM)

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

null 7 Dec 18, 2022
meg4cyberc4t 11 Oct 24, 2022
Flutter Getx Template

This is source flutter template use getx for statemanagement ☕

Dao Hong Vinh 43 Oct 18, 2022
flutter 2.x and getx v4.x template

flutter_getx_template Language: 中文简体 | English 基于getx 实现的全新flutter getx 模版,适用于中大型项目的开发。 ?? flutter最新版本的空安全 ?? view 和 逻辑 完全解耦 ⚡ view 和 state 自动响应 ?? di

xieyezi 192 Dec 19, 2022
Flutter-GetX-Toturials - Getx full tutorials for flutter

getx_full_tutorials A new Flutter getx tutorial. This Project Contains: Snackbar

Inzimam Bhatti 2 Dec 1, 2022
constructing... Flutter, Ganache, Truffle, Remix, Getx Pattern, Infura, GetX, Blockchain

constructing... Flutter, Ganache, Truffle, Remix, Getx Pattern, Infura, GetX, Blockchain

Kauê Murakami 20 Dec 20, 2022
WooCommerce App template that uses Flutter. Integrated to work with WooCommerce stores, connect and create an IOS and Android app from Flutter for IOS and Android

WooCommerce App: Label StoreMax Label StoreMax - v5.3.1 Official WooSignal WooCommerce App About Label StoreMax Label StoreMax is an App Template for

WooSignal 314 Jan 9, 2023
Now UI Flutter is a fully coded app template built for Flutter which will allow you to create powerful and beautiful e-commerce mobile applications

Now UI Flutter is a fully coded app template built for Flutter which will allow you to create powerful and beautiful e-commerce mobile applications. We have redesigned all the usual components to make it look like our Now UI Design, minimalistic and easy to use.

null 12 Oct 9, 2022
Readky is a Free Flutter News App Starter Template that can help you develop a News application much faster.

Readky. Introduction Readky is a Free Flutter News App Starter Template that can help you develop a News application much faster. You just need to add

Muhammad Rezky Sulihin 54 Nov 26, 2022