From f3be26d1363d7567007b5c0f439a6c211eadc582 Mon Sep 17 00:00:00 2001 From: Caleb Jasik Date: Tue, 4 Mar 2025 10:54:12 -0600 Subject: [PATCH] Remove unneccesary Container instances --- lib/components/CIDRField.dart | 83 +++++++++++++++--------------- lib/components/IPAndPortField.dart | 75 +++++++++++++-------------- 2 files changed, 78 insertions(+), 80 deletions(-) diff --git a/lib/components/CIDRField.dart b/lib/components/CIDRField.dart index ae584ca..73fc010 100644 --- a/lib/components/CIDRField.dart +++ b/lib/components/CIDRField.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'package:mobile_nebula/components/SpecialTextField.dart'; import 'package:mobile_nebula/models/CIDR.dart'; + import '../services/utils.dart'; import 'IPField.dart'; @@ -52,57 +53,55 @@ class _CIDRFieldState extends State { Widget build(BuildContext context) { var textStyle = CupertinoTheme.of(context).textTheme.textStyle; - return Container( - child: Row( - children: [ - Expanded( - child: Padding( - padding: EdgeInsets.fromLTRB(6, 6, 2, 6), - child: IPField( - help: widget.ipHelp, - ipOnly: true, - textPadding: EdgeInsets.all(0), - textInputAction: TextInputAction.next, - textAlign: TextAlign.end, - focusNode: widget.focusNode, - nextFocusNode: bitsFocus, - onChanged: (val) { - if (widget.onChanged == null) { - return; - } - - cidr.ip = val; - widget.onChanged!(cidr); - }, - controller: widget.ipController, - ), - ), - ), - Text("/"), - Container( - width: Utils.textSize("bits", textStyle).width + 12, - padding: EdgeInsets.fromLTRB(2, 6, 6, 6), - child: SpecialTextField( - keyboardType: TextInputType.number, - focusNode: bitsFocus, - nextFocusNode: widget.nextFocusNode, - controller: widget.bitsController, + return Row( + children: [ + Expanded( + child: Padding( + padding: EdgeInsets.fromLTRB(6, 6, 2, 6), + child: IPField( + help: widget.ipHelp, + ipOnly: true, + textPadding: EdgeInsets.all(0), + textInputAction: TextInputAction.next, + textAlign: TextAlign.end, + focusNode: widget.focusNode, + nextFocusNode: bitsFocus, onChanged: (val) { if (widget.onChanged == null) { return; } - cidr.bits = int.tryParse(val) ?? 0; + cidr.ip = val; widget.onChanged!(cidr); }, - maxLength: 2, - inputFormatters: [FilteringTextInputFormatter.digitsOnly], - textInputAction: widget.textInputAction ?? TextInputAction.done, - placeholder: 'bits', + controller: widget.ipController, ), ), - ], - ), + ), + Text("/"), + Container( + width: Utils.textSize("bits", textStyle).width + 12, + padding: EdgeInsets.fromLTRB(2, 6, 6, 6), + child: SpecialTextField( + keyboardType: TextInputType.number, + focusNode: bitsFocus, + nextFocusNode: widget.nextFocusNode, + controller: widget.bitsController, + onChanged: (val) { + if (widget.onChanged == null) { + return; + } + + cidr.bits = int.tryParse(val) ?? 0; + widget.onChanged!(cidr); + }, + maxLength: 2, + inputFormatters: [FilteringTextInputFormatter.digitsOnly], + textInputAction: widget.textInputAction ?? TextInputAction.done, + placeholder: 'bits', + ), + ), + ], ); } diff --git a/lib/components/IPAndPortField.dart b/lib/components/IPAndPortField.dart index 3f48722..4296491 100644 --- a/lib/components/IPAndPortField.dart +++ b/lib/components/IPAndPortField.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'package:mobile_nebula/components/SpecialTextField.dart'; import 'package:mobile_nebula/models/IPAndPort.dart'; + import '../services/utils.dart'; import 'IPField.dart'; @@ -58,49 +59,47 @@ class _IPAndPortFieldState extends State { Widget build(BuildContext context) { var textStyle = CupertinoTheme.of(context).textTheme.textStyle; - return Container( - child: Row( - children: [ - Expanded( - child: Padding( - padding: EdgeInsets.fromLTRB(6, 6, 2, 6), - child: IPField( - help: widget.ipHelp, - ipOnly: widget.ipOnly, - nextFocusNode: _portFocus, - textPadding: EdgeInsets.all(0), - textInputAction: TextInputAction.next, - focusNode: widget.focusNode, - onChanged: (val) { - _ipAndPort.ip = val; - widget.onChanged(_ipAndPort); - }, - textAlign: widget.ipTextAlign, - controller: widget.ipController, - ), - ), - ), - Text(":"), - Container( - width: Utils.textSize("00000", textStyle).width + 12, - padding: EdgeInsets.fromLTRB(2, 6, 6, 6), - child: SpecialTextField( - keyboardType: TextInputType.number, - focusNode: _portFocus, - nextFocusNode: widget.nextFocusNode, - controller: widget.portController, + return Row( + children: [ + Expanded( + child: Padding( + padding: EdgeInsets.fromLTRB(6, 6, 2, 6), + child: IPField( + help: widget.ipHelp, + ipOnly: widget.ipOnly, + nextFocusNode: _portFocus, + textPadding: EdgeInsets.all(0), + textInputAction: TextInputAction.next, + focusNode: widget.focusNode, onChanged: (val) { - _ipAndPort.port = int.tryParse(val); + _ipAndPort.ip = val; widget.onChanged(_ipAndPort); }, - maxLength: 5, - inputFormatters: [FilteringTextInputFormatter.digitsOnly], - textInputAction: TextInputAction.done, - placeholder: 'port', + textAlign: widget.ipTextAlign, + controller: widget.ipController, ), ), - ], - ), + ), + Text(":"), + Container( + width: Utils.textSize("00000", textStyle).width + 12, + padding: EdgeInsets.fromLTRB(2, 6, 6, 6), + child: SpecialTextField( + keyboardType: TextInputType.number, + focusNode: _portFocus, + nextFocusNode: widget.nextFocusNode, + controller: widget.portController, + onChanged: (val) { + _ipAndPort.port = int.tryParse(val); + widget.onChanged(_ipAndPort); + }, + maxLength: 5, + inputFormatters: [FilteringTextInputFormatter.digitsOnly], + textInputAction: TextInputAction.done, + placeholder: 'port', + ), + ), + ], ); }