Skip to content

Instantly share code, notes, and snippets.

View Temidtech's full-sized avatar
🏠
Working from home

Temidayo Adefioye Temidtech

🏠
Working from home
View GitHub Profile
String assetName = call.argument("asset");
String assetLookupKey = registrar.lookupKeyForAsset(assetName);
AssetFileDescriptor fd = registrar.context().getAssets().openFd(assetLookupKey);
player = new VideoPlayer(eventChannel, handle, fd, result);
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);
}
@Temidtech
Temidtech / main3.dart
Created April 14, 2018 00:03
main3 Dart File
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),
);
}
@Temidtech
Temidtech / errorm.dart
Last active April 14, 2018 00:09
errormessage
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)
@Temidtech
Temidtech / AndroidConnectivity.java
Created April 19, 2018 08:26
Sequence your network requests in android
//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);
@Temidtech
Temidtech / DynamicPlaceHolder.java
Created April 19, 2018 08:40
Selecting Colors with the Palette API
// SetUp the Library
android {
compileSdkVersion 26
...
}
dependencies {
...
implementation 'com.android.support:palette-v7:27.1.1'
}
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
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"
//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
//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() }