Skip to content

Instantly share code, notes, and snippets.

@asarazan
Last active June 4, 2018 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save asarazan/b3c23bef49cf9a61f5a1a19de746f1b0 to your computer and use it in GitHub Desktop.
Save asarazan/b3c23bef49cf9a61f5a1a19de746f1b0 to your computer and use it in GitHub Desktop.
Comparing Flutter to what it might look like in Kotlin
/**
* This is a quick proof of concept to illustrate how the principles of Kotlin/Anko could be used to make Flutter
* more designer-friendly.
*
* @see Single Expression Functions (https://kotlinlang.org/docs/reference/functions.html#single-expression-functions)
* @see Groovy-Style Builders (https://kotlinlang.org/docs/reference/type-safe-builders.html)
* @see Extension Functions/Properties (https://kotlinlang.org/docs/reference/extensions.html#extension-properties)
* @see Anko Layouts (https://github.com/Kotlin/anko#anko-layouts-wiki)
*/
class TutorialHome : StatelessWidget {
override
fun build(context: BuildContext) = scaffold {
appBar = appBar {
leading = iconButton {
iconImage = Icons.menu
tooltip = "Navigation menu"
}
titleText = "Example title"
actions = [ // based on https://twitter.com/abreslav/status/867714627060322305
iconButton {
iconImage = Icons.search
tooltip = "Search"
}
]
}
body = center {
// Remember: This is a fully functional programming environment. You can execute any code you can think of.
childText = "Hello ${MyApp.users.me.fullName.split(" ").first}"!
}
floatingActionButton = fab {
tooltip = "Add"
childImage = Icons.add
}
}
}
class TutorialHome extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Scafold is a layout for the major material design widgets.
return new Scaffold(
appBar: new AppBar(
leading: new IconButton(
icon: new Icon(Icons.menu),
tooltip: 'Navigation menu',
onPressed: null,
),
title: new Text('Example title'),
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.search),
tooltip: 'Search',
onPressed: null,
),
],
),
// body is the majority of the screen.
body: new Center(
child: new Text('Hello, world!'),
),
floatingActionButton: new FloatingActionButton(
tooltip: 'Add', // used by assistive technologies
child: new Icon(Icons.add),
onPressed: null,
),
);
}
}
@gaara87
Copy link

gaara87 commented Oct 1, 2017

kotlin sure does look better

@IgorGanapolsky
Copy link

Is it worthwhile to learn Flutter? Or just sticking to Kotlin is a sure bet for the next decade.

@dron247
Copy link

dron247 commented Nov 23, 2017

@IgorGanapolsky флаттер - это немного про другое, это ненативный гуй абстрагированный от платформы в первую очередь, рисует уи на предоставленном контексте вполне кроссплатформенно и главное быстро, как в играх подход в целом

@raveesh-me
Copy link

IMHO both are much better than JAVA

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