text
stringlengths 1
372
|
---|
'this widget has not observed any lifecycle changes.',
|
textDirection: TextDirection.ltr,
|
);
|
}
|
return text(
|
'the most recent lifecycle state this widget observed was: $_lastLifecycleState.',
|
textDirection: TextDirection.ltr,
|
);
|
}
|
}
|
void main() {
|
runApp(const center(child: LifecycleWatcher()));
|
}
|
<code_end>
|
<topic_end>
|
<topic_start>
|
layouts
|
<topic_end>
|
<topic_start>
|
what is the equivalent of a LinearLayout?
|
in android, a LinearLayout is used to lay your widgets out
|
linearly—either horizontally or vertically.
|
in flutter, use the row or column
|
widgets to achieve the same result.
|
if you notice the two code samples are identical with the exception of the
|
“row” and “column” widget. the children are the same and this feature can be
|
exploited to develop rich layouts that can change overtime with the same
|
children.
|
<code_start>
|
@override
|
widget build(BuildContext context) {
|
return const row(
|
mainAxisAlignment: MainAxisAlignment.center,
|
children: <widget>[
|
Text('Row one'),
|
Text('Row two'),
|
Text('Row three'),
|
Text('Row four'),
|
],
|
);
|
}
|
<code_end>
|
<code_start>
|
@override
|
widget build(BuildContext context) {
|
return const column(
|
mainAxisAlignment: MainAxisAlignment.center,
|
children: <widget>[
|
Text('Column one'),
|
Text('Column two'),
|
Text('Column three'),
|
Text('Column four'),
|
],
|
);
|
}
|
<code_end>
|
to learn more about building linear layouts,
|
see the community-contributed medium article
|
flutter for android developers: how to design LinearLayout in flutter.
|
<topic_end>
|
<topic_start>
|
what is the equivalent of a RelativeLayout?
|
a RelativeLayout lays your widgets out relative to each other. in
|
flutter, there are a few ways to achieve the same result.
|
you can achieve the result of a RelativeLayout by using a combination of
|
column, row, and stack widgets. you can specify rules for the widgets
|
constructors on how the children are laid out relative to the parent.
|
for a good example of building a RelativeLayout in flutter,
|
see collin’s answer on StackOverflow.
|
<topic_end>
|
<topic_start>
|
what is the equivalent of a ScrollView?
|
in android, use a ScrollView to lay out your widgets—if the user’s
|
device has a smaller screen than your content, it scrolls.
|
in flutter, the easiest way to do this is using the ListView widget.
|
this might seem like overkill coming from android,
|
but in flutter a ListView widget is
|
both a ScrollView and an android ListView.
|
<code_start>
|
@override
|
widget build(BuildContext context) {
|
return ListView(
|
children: const <widget>[
|
Text('Row one'),
|
Text('Row two'),
|
Text('Row three'),
|
Text('Row four'),
|
],
|
);
|
}
|
<code_end>
|
<topic_end>
|
<topic_start>
|
how do i handle landscape transitions in flutter?
|
FlutterView handles the config change if AndroidManifest.xml contains:
|
<topic_end>
|
<topic_start>
|
gesture detection and touch event handling
|
<topic_end>
|
<topic_start>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.