From 12938e6b936f478ccddf61bb7bb366945dd70d54 Mon Sep 17 00:00:00 2001 From: David Senk Date: Fri, 6 Sep 2024 20:43:01 -0400 Subject: [PATCH] abstracted into safezone --- lib/About.dart | 17 ++++++----------- lib/SafeZone.dart | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 lib/SafeZone.dart diff --git a/lib/About.dart b/lib/About.dart index e67949d..3f7d776 100644 --- a/lib/About.dart +++ b/lib/About.dart @@ -1,21 +1,16 @@ import 'package:flutter/material.dart'; +import 'package:ything_radio/SafeZone.dart'; class About extends StatelessWidget { const About({super.key}); @override Widget build(BuildContext context) { - final safeLeftPadding = MediaQuery.of(context).padding.left + 16; - final safeRightPadding = MediaQuery.of(context).padding.right + 16; - final safeBottomPadding = MediaQuery.of(context).padding.bottom; - final safeTopPadding = MediaQuery.of(context).padding.top; - - return DefaultTextStyle( - style: Theme.of(context).textTheme.bodyLarge!, - child: SingleChildScrollView( - child: Padding( - padding: EdgeInsets.only(left: safeLeftPadding, right: safeRightPadding, bottom: safeBottomPadding, top: safeTopPadding), - child: const Text( + return SafeZone( + child: DefaultTextStyle( + style: Theme.of(context).textTheme.bodyLarge!, + child: const SingleChildScrollView( + child: Text( 'Ything Radio is an app that is intended to provide a demonstration of the ' 'open source ything_radio app. This app is used to provide the ability for the ' '"look and feel" of the app to be tested on real devices for those wishing to ' diff --git a/lib/SafeZone.dart b/lib/SafeZone.dart new file mode 100644 index 0000000..beca2d2 --- /dev/null +++ b/lib/SafeZone.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; + +class SafeZone extends StatelessWidget { + const SafeZone({super.key, required this.child}); + + final Widget child; + + @override + Widget build(BuildContext context) { + final safeLeftPadding = MediaQuery.of(context).padding.left + 16; + final safeRightPadding = MediaQuery.of(context).padding.right + 16; + final safeBottomPadding = MediaQuery.of(context).padding.bottom + 16; + final safeTopPadding = MediaQuery.of(context).padding.top + 16; + + return Padding( + padding: EdgeInsets.only( + left: safeLeftPadding, + right: safeRightPadding, + bottom: safeBottomPadding, + top: safeTopPadding), + child: child, + ); + } +}