Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created December 16, 2025 18:31
Show Gist options
  • Select an option

  • Save fredgrott/ddfa77633518c00735b6261285053ba4 to your computer and use it in GitHub Desktop.

Select an option

Save fredgrott/ddfa77633518c00735b6261285053ba4 to your computer and use it in GitHub Desktop.
BuildContextExt
// Copyright 2025 Fredrick Allan Grott. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
import 'dart:math';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:universal_platform/universal_platform.dart';
/// BuildContextExt is the extensions that
/// are not MediaQuery based.
///
/// @author Fredrick Allan Grott
extension BuildContextExt on BuildContext {
ThemeData get theme => Theme.of(this);
TextTheme get textTheme => theme.textTheme;
TextTheme get primaryTextTheme => theme.primaryTextTheme;
ColorScheme get colorScheme => theme.colorScheme;
DefaultTextStyle get defaultTextStyle => DefaultTextStyle.of(this);
NavigatorState get navigator => Navigator.of(this);
FocusScopeNode get focusScope => FocusScope.of(this);
ScaffoldMessengerState get scaffoldMessenger => ScaffoldMessenger.of(this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment