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
String assetName = call.argument("asset"); | |
String assetLookupKey = registrar.lookupKeyForAsset(assetName); | |
AssetFileDescriptor fd = registrar.context().getAssets().openFd(assetLookupKey); | |
player = new VideoPlayer(eventChannel, handle, fd, result); |
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
void main() { | |
List todo = ['Drink', 'Chat', new Task('Code Flutter', Priority.high), 'Profit']; | |
runApp( | |
new MaterialApp(home: new MyTodoList(todo)), | |
); | |
} | |
class MyTodoList extends StatefulWidget { | |
final List<Widget> items; | |
MyTodoList(this.items); | |
} |
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
Widget build(BuildContext context) { | |
List<Widget> remaining = widget.items.sublist(_done); | |
return new Scaffold( | |
body: (remaining.length <= 3) | |
? new Column(children: remaining) | |
: new Text('${remaining.length} items left to do'), | |
floatingActionButton: new FloatingActionButton(onPressed: _doOneThing), | |
); | |
} |
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
type 'List<dynamic>' is not a subtype of type 'List<Widget>' where | |
List is from dart:core | |
Object is from dart:core | |
List is from dart:core | |
Widget is from package:flutter/src/widgets/framework.dart | |
main (file:///Users/temidjoy/tmp/todo/lib/main2.dart:4:37) |
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 code snippet tests network connectivity for Wi-Fi and mobile. | |
//It determines whether these network interfaces are available | |
//(that is, whether network connectivity is possible) and/or | |
//connected (that is, whether network connectivity exists and | |
//if it is possible to establish sockets and pass data): | |
private static final String DEBUG_TAG = "NetworkStatusExample"; | |
... | |
ConnectivityManager connMgr = (ConnectivityManager) | |
getSystemService(Context.CONNECTIVITY_SERVICE); |
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
// SetUp the Library | |
android { | |
compileSdkVersion 26 | |
... | |
} | |
dependencies { | |
... | |
implementation 'com.android.support:palette-v7:27.1.1' | |
} |
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
var output: String | |
output = null // Compilation error | |
================================== | |
val name: String? = null // Nullable type | |
println(name.length()) // Compilation error | |
val nonNullableString = nullableString ?: "" //returns empty string if variable is null |
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
import kotlinx.android.synthetic.main.content_main.* | |
class LoginActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
// No need to call findViewById(R.id.textView) as TextView | |
userName.text = "temidayo" |
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
//Declare a Person Class | |
data class Person(val name: String) { | |
var age: Int = 0 | |
} | |
val person1 = Person("John") | |
val person2 = Person("John") | |
person1.age = 10 |
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
//jAVA code to set Onclick event to a button | |
button.setOnClickListener(new View.OnClickListener(){ | |
@Override | |
public void onClick(View v){ | |
doSomething(); | |
} | |
}); | |
//Kotlin gets it done in 1 line.. | |
button.setOnClickListener { doSomething() } |
OlderNewer