Skip to content

Instantly share code, notes, and snippets.

@pedromassango
Created December 27, 2018 23:11
Show Gist options
  • Save pedromassango/13eaf16e03cc716ebc9c54d06947aaf7 to your computer and use it in GitHub Desktop.
Save pedromassango/13eaf16e03cc716ebc9c54d06947aaf7 to your computer and use it in GitHub Desktop.
This code split a flutter app into two parts.
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Positioned(
top: 0,
bottom: MediaQuery.of(context).size.height / 2,
width: double.maxFinite,
child: Container(
color: Colors.orangeAccent,
),
),
Positioned(
top: (MediaQuery.of(context).size.height / 2),
bottom: 0,
width: double.maxFinite,
child: Container(
color: Colors.red,
))
],
) // This trailing comma makes auto-formatting nicer for build methods.
);
}
@benjamindean
Copy link

Just a suggestion: Trailing comma everywhere makes formatting nicer. When I started learning Dart, I couldn't understand why the formatting is so ugly until I figured that out.

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: <Widget>[
          Positioned(
            top: 0,
            bottom: MediaQuery.of(context).size.height / 2,
            width: double.maxFinite,
            child: Container(
              color: Colors.orangeAccent,
            ),
          ),
          Positioned(
            top: MediaQuery.of(context).size.height / 2,
            bottom: 0,
            width: double.maxFinite,
            child: Container(
              color: Colors.red,
            ),
          ),
        ],
      ),
    );
  }
}

@pedromassango
Copy link
Author

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment