Last active
June 4, 2018 11:46
-
-
Save asarazan/b3c23bef49cf9a61f5a1a19de746f1b0 to your computer and use it in GitHub Desktop.
Comparing Flutter to what it might look like in Kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | |
), | |
); | |
} | |
} |
Is it worthwhile to learn Flutter? Or just sticking to Kotlin is a sure bet for the next decade.
@IgorGanapolsky флаттер - это немного про другое, это ненативный гуй абстрагированный от платформы в первую очередь, рисует уи на предоставленном контексте вполне кроссплатформенно и главное быстро, как в играх подход в целом
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
kotlin sure does look better