Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created April 22, 2024 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredgrott/06f1b4ae4c63564a51f8ffd869db9454 to your computer and use it in GitHub Desktop.
Save fredgrott/06f1b4ae4c63564a51f8ffd869db9454 to your computer and use it in GitHub Desktop.
app globals
// Copyright 2024 Fredrick Allan Hrott. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
// So this is how we will get the context to use in any models as
// the scaffoldMessengerKey will be supplied to the MaterialApp
// and then the appRouterContext will be the context referred to
// in the AppLocalisations.of().localizationKey call in the model
// as this then can be repeated when we use the MaterialApp wrapper
// to unit test the model in unit tests.
final scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
BuildContext? appRouterContext = scaffoldMessengerKey.currentContext;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment