import 'package:flutter/material.dart'; class AppContext { static late BuildContext _context; AppContext._(); ///私有构造函数,防止外部实例化 static void setContent(BuildContext context) { _context = context; } ///获取全局上下文 static BuildContext get context => _context; ///获取主题 static TextTheme get textTheme => Theme.of(_context).textTheme; static ColorScheme get colorScheme => Theme.of(_context).colorScheme; ///页面内间距 static double get pagePadding => 15; }