CupertinoFormRow class
An iOS-style form row.
Creates an iOS-style split form row with a standard prefix and child widget. Also provides a space for error and helper widgets that appear underneath.
The child parameter is required. This widget is displayed at the end of the row.
The prefix parameter is optional and is displayed at the start of the row. Standard iOS guidelines encourage passing a Text widget to prefix to detail the nature of the row's child widget.
The padding parameter is used to pad the contents of the row. It defaults to the standard iOS padding. If no edge insets are intended, explicitly pass EdgeInsets.zero to padding.
The helper and error parameters are both optional widgets targeted at displaying more information about the row. Both widgets are placed underneath the prefix and child, and will expand the row's height to accommodate for their presence. When a Text is given to error, it will be shown in CupertinoColors.destructiveRed coloring and medium-weighted font.
Creates a CupertinoFormSection containing a CupertinoFormRow with prefix, child, helper and error specified.
To see it in action, copy and run this code snippet on DartPad.
import 'package:cupertino_ui/cupertino_ui.dart';
/// Flutter code sample for [CupertinoFormRow].
void main() => runApp(const CupertinoFormRowApp());
class CupertinoFormRowApp extends StatelessWidget {
const CupertinoFormRowApp({super.key});
@override
Widget build(BuildContext context) {
return const CupertinoApp(
theme: CupertinoThemeData(brightness: .light),
home: CupertinoFormRowExample(),
);
}
}
class CupertinoFormRowExample extends StatefulWidget {
const CupertinoFormRowExample({super.key});
@override
State<CupertinoFormRowExample> createState() =>
_CupertinoFormRowExampleState();
}
class _CupertinoFormRowExampleState extends State<CupertinoFormRowExample> {
bool airplaneMode = false;
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('CupertinoFormSection Sample'),
),
// Add safe area widget to place the CupertinoFormSection below the navigation bar.
child: SafeArea(
child: CupertinoFormSection(
header: const Text('Connectivity'),
children: <Widget>[
CupertinoFormRow(
prefix: const PrefixWidget(
icon: CupertinoIcons.airplane,
title: 'Airplane Mode',
color: CupertinoColors.systemOrange,
),
child: CupertinoSwitch(
value: airplaneMode,
onChanged: (bool value) {
setState(() {
airplaneMode = value;
});
},
),
),
const CupertinoFormRow(
prefix: PrefixWidget(
icon: CupertinoIcons.wifi,
title: 'Wi-Fi',
color: CupertinoColors.systemBlue,
),
error: Text('Home network unavailable'),
child: Row(
mainAxisAlignment: .end,
children: <Widget>[
Text('Not connected'),
SizedBox(width: 5),
Icon(CupertinoIcons.forward),
],
),
),
const CupertinoFormRow(
prefix: PrefixWidget(
icon: CupertinoIcons.bluetooth,
title: 'Bluetooth',
color: CupertinoColors.activeBlue,
),
helper: Padding(
padding: .symmetric(vertical: 4.0),
child: Row(
mainAxisAlignment: .spaceBetween,
children: <Widget>[Text('Headphone'), Text('Connected')],
),
),
child: Row(
mainAxisAlignment: .end,
children: <Widget>[
Text('On'),
SizedBox(width: 5),
Icon(CupertinoIcons.forward),
],
),
),
const CupertinoFormRow(
prefix: PrefixWidget(
icon: CupertinoIcons.bluetooth,
title: 'Mobile Data',
color: CupertinoColors.systemGreen,
),
child: Icon(CupertinoIcons.forward),
),
],
),
),
);
}
}
class PrefixWidget extends StatelessWidget {
const PrefixWidget({
super.key,
required this.icon,
required this.title,
required this.color,
});
final IconData icon;
final String title;
final Color color;
@override
Widget build(BuildContext context) {
return Row(
children: <Widget>[
Container(
padding: const .all(4.0),
decoration: BoxDecoration(color: color, borderRadius: .circular(4.0)),
child: Icon(icon, color: CupertinoColors.white),
),
const SizedBox(width: 15),
Text(title),
],
);
}
}
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- CupertinoFormRow
Constructors
- CupertinoFormRow({Key? key, required Widget child, Widget? prefix, EdgeInsetsGeometry? padding, Widget? helper, Widget? error})
-
Creates an iOS-style split form row with a standard prefix and child widget.
Also provides a space for error and helper widgets that appear underneath.
const
Properties
- child → Widget
-
Child widget.
final
- error → Widget?
-
A widget that is displayed underneath the prefix and child widgets.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- helper → Widget?
-
A widget that is displayed underneath the prefix and child widgets.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- padding → EdgeInsetsGeometry?
-
Content padding for the row.
final
- prefix → Widget?
-
A widget that is displayed at the start of the row.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited