🎨 An opinionated, effective and correct way to provide multiple themes to your app.

Overview

theming

This is an opinionated and effective way to provide multi-theme choice for your app.

theming depends on provider and shared_preference for state management and data retention respectively.

theming solves the issue of loading a default theme on the app startup before fetching last theme state from shared pref. After seeing this issue in two public articles, i decided to give it a try :shipit:

key code

in main() and before runApp() is loaded, a single instance of SharedPreferences (none is created again thoughout the app) is created and passed into ThemeProvider. This is bacause it is imperative to acquire the last/previous theme state before loading the app. yes, themeProvider.assertTheme().

final pref = await SharedPreferences.getInstance();
  ThemeProvider themeProvider = ThemeProvider(pref);
  themeProvider.assertTheme();

the key to retaining the value of themeProvider.assertTheme() is assigning relevant data it to a static variable.

static ThemeData? _themeData;

_themeData retains its value through the creation and recreation of the ThemeProvider object in app's lifecycle.

in what is relevant here, our variable of type ThemeData will work our trick.

if you find this repo useful, make sure to star 🌟 it. thank you.

You might also like...

The easiest way to create your animated splash screen in a fully customizable way.

The easiest way to create your animated splash screen in a fully customizable way.

Animated Splash Screen Check it out at Pub.Dev Do it your way Assets image Custom Widget Url image IconData Or just change PageTransition and/or Splas

Nov 10, 2022

TRTCFlutterDemo - With TRTC, you can quickly develop cost-effective, low-latency, and high-quality interactive audio/video services

TRTCFlutterDemo - With TRTC, you can quickly develop cost-effective, low-latency, and high-quality interactive audio/video services

This document describes how to quickly run the TRTC demo for Flutter. Environmen

Feb 10, 2022

The XOR Encryption algorithm is a effective and easy to implement method of symmetric encryption.

Symmetric XOR cipher library About XOR cipher XOR Encryption is an encryption method used to encrypt data and is hard to crack by brute-force method,

Apr 20, 2022

A lightweight & effective Todo app made with Flutter

A lightweight & effective Todo app made with Flutter

Blue Diary A lightweight & effective Todo app made with Flutter. Supports English and Korean. Screenshots β€’ Download β€’ Usage β€’ Architecture β€’ Feedback

Dec 6, 2022

A super effective dart library delivering performance & ensuring greater build speed.

A super effective dart library delivering performance & ensuring greater build speed.

A super effective Dart and Flutter library for delivering performante app 🌝 & ensuring greater build speed πŸš€ . The package has some cook utilizes wh

Nov 22, 2021

Linter rules corresponding to the guidelines in Effective Dart

effective_dart This package is deprecated. Before it was deprecated, it was the way to provide analysis options corresponding to the guidelines in Eff

Dec 9, 2022

This perfect starter kit is an app based on React Native and UI Kitten library with Light and Dark themes support.

This perfect starter kit is an app based on React Native and UI Kitten library with Light and Dark themes support.

Kitten Tricks This perfect starter kit is an app based on React Native and UI Kitten library with Light and Dark themes support. It’s completely free

Dec 30, 2022

The Flutter plugin that help you can choose dates and years with rounded calendars and customizable themes.

The Flutter plugin that help you can choose dates and years with rounded calendars and customizable themes.

Flutter Rounded Date Picker The Flutter plugin that help you can choose dates and years with rounded calendars and customizable themes. Installing Add

Dec 22, 2022
Owner
Chinyeaka Chinonso
Engineering
Chinyeaka Chinonso
Lite version of smart_select package, zero dependencies, an easy way to provide a single or multiple choice chips.

Lite version of smart_select package, zero dependencies, an easy way to provide a single or multiple choice chips. What's New in Version 2.x.x Added p

Irfan Vigma Taufik 97 Dec 15, 2022
Flutter bloc infinite list - A sample application to learn flutter bloc the correct way

flutter_bloc_infinite_list A sample application to learn flutter bloc the correc

Anoop TM 2 Aug 22, 2022
Flutter chat-app UI with multiple themes & light + Dark mode.

Chat-App UI Only a PART of code available, for complete code ping here Features of the app - Light Mode + Dark Mode 4 different color themes - pink/te

Deepa Pandey 31 Oct 5, 2022
An opinionated, community-driven set of lint rules for Dart and Flutter projects. Like pedantic but stricter

Lint for Dart/Flutter lint is a hand-picked, open-source, community-driven collection of lint rules for Dart and Flutter projects. The set of rules fo

Pascal Welsch 257 Jan 3, 2023
Flying Fish is full-stack Dart framework - a semi-opinionated framework for building applications exclusively using Dart and Flutter

Flying Fish is full-stack Dart framework - a semi-opinionated framework for building applications exclusively using Dart and Flutter.

Flutter Fish 3 Dec 27, 2022
This is an opinionated code-generation tool from GraphQL to Dart/Flutter.

GraphQL Codegen This is an opinionated code-generation tool from GraphQL to Dart/Flutter. It'll allow you to generate Dart serializers and client help

United Traders 1 Dec 29, 2021
This application was created using the Dart language and it is an application that contains a set of different questions and at the end shows you the number of correct answers you have answered , made by flutter

exams_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if thi

null 0 Dec 28, 2021
null 0 Feb 2, 2022
Flutter package to get keyboard height. Can be used to display a sticker/emoji modal with correct height.

flutter_persistent_keyboard_height Flutter package to get keyboard height. The height is persisted during app sessions and keyboard states (you can us

Arshak Aghakaryan 13 Oct 17, 2022
An Ai Game That Solve The problem of finding the correct path from source to destination

Monkey And Banana AI Game An Ai Game That Solve The problem of finding the correct path from source to destination . Use BeathFirst Algorithm. Game Ap

null 0 May 10, 2022