• Stars
    star
    136
  • Rank 259,275 (Top 6 %)
  • Language
    Dart
  • License
    MIT License
  • Created about 4 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Access most used properties in your BuildContext instance.

Languages: English | Brazilian Portuguse

Logo

BuildContext

Access most used properties in your BuildContext instance. This package relies on Dart's extension to provide easy access for the most used properties and functions that depends on the BuildContext instance.

Available Extensions

I update this package frequently to add more extensions, bellow you can see the currently available extensions in the latest version.

From the MediaQuery. Access properties right in the context instance. Available extensions:

  • context.mediaQuerySize

  • context.orientation

  • context.mediaQueryPadding

  • context.alwaysUse24HourFormat

  • context.devicePixelRatio

  • context.platformBrightness

  • context.textScaleFactor

  • context.isLandscape

  • context.isPortrait

  • context.mediaQueryViewPadding

  • context.mediaQueryViewInsets

  • context.mediaQueryShortestSide

  • context.isPhone

  • context.isTablet

  • context.isSmallTablet

  • context.isLargeTablet

From the Navigator class. Navigate with ease. Available extensions:

  • context.push()
  • context.pop()
  • context.canPop()
  • context.pushNamed()
  • context.popUntil()

From the Theme class. Access your themes right in the context instance. Available extensions:

  • context.theme
  • context.textTheme
  • context.primaryTextTheme
  • context.accentTextTheme
  • context.bottomAppBarTheme
  • context.bottomSheetTheme
  • context.appBarTheme
  • context.backgroundColor
  • context.primaryColor
  • context.buttonColor
  • context.scaffoldBackgroundColor
  • context.platform
  • context.isAndroid
  • context.isIOS
  • context.isWindows
  • context.isMacOS
  • context.isLinux
  • context.isFuchsia
  • context.headline1
  • context.headline2
  • context.headline3
  • context.headline4
  • context.headline5
  • context.headline6
  • context.subtitle1
  • context.bodyText1
  • context.bodyText2
  • context.caption
  • context.button
  • context.subtitle2
  • context.overline

From Scaffold class. Handle your scaffold in their context.

Note: those must be called in the context of a Scaffold widget otherwise you might have errors.

  • context.openDrawer()
  • context.openEndDrawer()
  • context.showSnackBar()
  • context.hideCurrentSnackBar()
  • context.removeCurrentSnackBar()
  • context.showBottomSheet()

From Form.of(context) class.

Note: those must be called in the context of a Scaffold widget otherwise you might have errors.

  • context.form.validate()
  • context.form.reset()
  • context.form.save()

From FocusScope.of(context) class.

  • context.focusScope.hasFocus

  • context.focusScope.isFirstFocus

  • context.focusScope.canRequestFocus

  • context.focusScope.hasPrimaryFocus

  • context.focusScope.unfocus()

  • context.focusScope.nextFocus()

  • context.focusScope.requestFocus()

  • context.focusScope.previousFocus()

  • context.focusScope.setFirstFocus()

  • context.focusScope.consumeKeyboardToken()

  • context.closeKeyboard()

From ModalRoute.of(context) class.

  • context.modalRoute
  • context.routeSettings

Install

Add it in your pubspec.yaml:

dependencies:
  build_context: ^3.0.0

Import it where you want to use it e.g, in your widget's file.

import "package:build_context/build_context.dart";

Here is a usage example:

import 'package:flutter/material.dart';
import "package:build_context/build_context.dart";

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: context.scaffoldBackgroundColor, // There is no Theme.of(context)
      body: Center(
        child: GestureDetector(
          onTap: () => context.pushNamed('/detailsPage'), // we use only context not Navigator.of(context)
          child: Text(
            'Press Me',
            style: context.primaryTextTheme.title, // we use only context not Theme.of(context)
          ),
        ),
      ),
    );
  }
}

Support

You liked this package? then give it a star. If you want to help then:

  • Start this repository
  • Send a Pull Request with new features
  • Share this package
  • Create issues if you find a Bug or want to suggest something

More Repositories

1

my_flutter_challenges

Flutter project containing all my flutter UI challenges
Dart
1,012
star
2

bottom_navy_bar

A beautiful and animated bottom navigation
Dart
982
star
3

titled_navigation_bar

A beautiful and simple bottom navigation bar with smooth animation when switching selected item.
Dart
371
star
4

flutter_delivery

A flutter app with custom navigation drawer
Dart
281
star
5

xtimer-flutter-app

Flutter timer app
Dart
275
star
6

IBackdrop

A library to simply use Backdrop in your project (make it easy). Read more ->
Kotlin
139
star
7

flutter_famguard

A Flutter app for monitor members family
Dart
55
star
8

flutter-tasky-app

A Flutter Task App
Dart
53
star
9

bloc_example

BLoC pattern example
Dart
51
star
10

crazy-switch

A beautiful switch made with Flutter
Dart
50
star
11

doubleClick

A lib To handle double click on android View's components.
Java
48
star
12

catcher

A Multi-Platform game made with Flutter
Dart
29
star
13

booksy

A new Flutter app to read books provided by Google Books
Dart
24
star
14

slide_show_flutter

A simple animation challenge made with Flutter
C++
23
star
15

Delyo-Food-Delivery-Android

An Food Delivery concept UI.
Kotlin
21
star
16

slider_number_picker

Dart
20
star
17

Android-Advanced-Register-Login-UI

Android Advanced Register/Login design concept
Kotlin
17
star
18

banzo

Android app to learn languages
Kotlin
16
star
19

flutter_app_lifecycle

A new Flutter project that show you how to detect the app's lifecycle
Dart
16
star
20

flutter-bottomAppBar

Watch the tutorial video on Youtube ->
Dart
15
star
21

flutter_contest

Flutter project submitted on Flutter contest
Dart
14
star
22

crypto

Crypto is a currency app to converter coins and to see market stats.
Kotlin
13
star
23

appIntro

Um simples pacote para adicionar telas de introdução no seu aplicativo. Desenvolvido com a linguagem Kotlin.
Kotlin
11
star
24

AndroidCustomView

A sample of how to create custom view class (EditText with clear button)
Kotlin
11
star
25

Material-Design-Components-Sample

A repository to show all use case of Materia Design Components in Android
Kotlin
10
star
26

android-room-database-sample

Android Studio Room Database Sample
Kotlin
9
star
27

flutter-learning-path

Flutter learning path
8
star
28

Programmers

Uma rede social para programadores/desenvolvedores e amantes de tecnologias.
Java
8
star
29

alarm-manager-android

Scheduling Tasks with AlarmManager. Read more here ->
Kotlin
7
star
30

localize

A brand new localization service for your projects.
Dart
7
star
31

pedromassango

6
star
32

zero-football-app

A Football app made with Flutter
Dart
6
star
33

flutter_whatsapp_clone

A whatsapp clone using Flutter
Dart
6
star
34

flutter-hero

Project sample about Hero animation, read more here ->
Dart
6
star
35

movies_app

Dart
5
star
36

qr-code-scanner-sample

QR code scanner sample
Dart
5
star
37

startup-name-generator

Project made when studing in Google Code Lab. This is a simple startup name generator made with Flutter
Dart
5
star
38

herenow

A android location app based on user's contacts. Try it here ->
Kotlin
5
star
39

odd1out

Dart
5
star
40

flutter-navigator

This is repo contains sample code of Navigator in Flutter red more here
Dart
4
star
41

image_picker_example

This repository contains code to demostrate how to pick image from camera and gallery in Flutter
Dart
4
star
42

material-components-navigation-drawer

An android project showing a example of using the DawerLayout and NavigationView together
Kotlin
4
star
43

redux-sample

A Flutter project that implement redux state managment
Dart
4
star
44

flutter-architecture-samples

Flutter Architecture is a project to showcase different architectural approaches for Flutter projects. Its has different branches implementing the same app (a TODO app) using different architecture approaches..
4
star
45

architecture-bestpratice

Android project to show the best pratice with architecture components. The is a serie on Youtube, follow it ->
Kotlin
4
star
46

android-free-books

Um app para pesquisa, leitura e download de livros
Kotlin
3
star
47

inherited_widget_sample

A basic sample of InheritedWidget
Dart
3
star
48

flutter_as_android_module

Youtube video tutorial ->
Dart
3
star
49

qr_code_example

Qr code generator sample
Dart
3
star
50

chatty

This is an Android Chat App with Firebase
Java
3
star
51

android-koin

Android project that show the use of Koin for Dependency Injection with ViewModel and LiveData
Kotlin
2
star
52

fad

Dart
2
star
53

flutter_theme_sample

Dart
2
star
54

JobSchedulerSample

A JobScheduler android sample
Java
2
star
55

Healthy

Medical application for cDa Hackathon. App for control / management of vaccines.
Java
2
star
56

flutter-sliver-app-bar

Dart
2
star
57

flutter-changelog

Check the most important changes in the Flutter repository
C++
2
star
58

android-studio-bottom-navigation

A Sample of how to setup the Bottom Navigation View (from MaterialComponents Theme), with fragments
Kotlin
2
star
59

android-sqlite-java

A SQLite android database sample
Java
2
star
60

tap-android-game

Kotlin
2
star
61

smart_home

A Smart Home UI concept made with Flutter
Dart
2
star
62

FreeChat

Free FCM chat app
Java
1
star
63

keyper

An android project to store User's Passwords.
Java
1
star
64

algorithms-data-structures-with-kotlin

Kotlin
1
star
65

KotlinParcelize

An example of Kotlin Parcelize
Kotlin
1
star
66

Unit-Tests-Mockito

A project to learn unit tests with Mockito Library
1
star
67

redux_simple_counter_app

A basic counter app using Redux
Dart
1
star
68

pedromassango.github.io

My Portfolio made with Flutter
JavaScript
1
star
69

broadcastReceiver

A android broadcast receiver sample
Java
1
star
70

Console

Controle um computador pelo seu telefone Android
Kotlin
1
star
71

android-studio-databinding

Java
1
star
72

alc-challenge-android

Kotlin
1
star
73

kotlin-demo

Um conteiner de arquivos kotlin
Kotlin
1
star
74

AndroidKotlinCoroutines

Android project with kotlin coroutines sample
Kotlin
1
star