Skip to content

Instantly share code, notes, and snippets.

Vadym Pinchuk VadPinchuk

Block or report user

Report or block VadPinchuk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@VadPinchuk
VadPinchuk / styles.xml
Created Feb 25, 2020
Launch and Normal styles
View styles.xml
<style name="LaunchTheme" parent="@android:style/ThemeOverlay.Material.Dark">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:navigationBarColor">@color/brandGrey</item>
</style>
<style name="NormalTheme" parent="@android:style/ThemeOverlay.Material.Dark">
<item name="android:windowBackground">@drawable/normal_background</item>
</style>
@VadPinchuk
VadPinchuk / launch_background.xml
Created Feb 25, 2020
launch background drawable
View launch_background.xml
<?xml version="1.0" encoding="utf-8"?><!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/brandGrey" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher" />
</item>
View BaseActivity.kt
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) =
GeneratedPluginRegistrant.registerWith(flutterEngine)
View BaseActivity.kt
import androidx.annotation.NonNull
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
abstract class BaseActivity : FlutterActivity() {
abstract var entryPoint: String
override fun getDartEntrypointFunctionName() = entryPoint
View AndroidManifest.xml
<!-- Specify that the launch screen should continue being displayed -->
<!-- until Flutter renders its first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
<!-- Theme to apply as soon as Flutter begins rendering frames -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
@VadPinchuk
VadPinchuk / FlutterPlugin.kt
Created Feb 21, 2020
Method handling callback
View FlutterPlugin.kt
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
when (call.method) {
"getPlatformVersion" ->
result.success("Android ${android.os.Build.VERSION.RELEASE}")
else -> result.notImplemented()
}
}
@VadPinchuk
VadPinchuk / FlutterPlugin.kt
Created Feb 21, 2020
New attach/detach callback methods
View FlutterPlugin.kt
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
val channel = MethodChannel(flutterPluginBinding.binaryMessenger, "flutter_plugin")
channel.setMethodCallHandler(FlutterPlugin())
}
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
}
View FlutterPlugin.kt
override fun onDetachedFromActivity() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
@VadPinchuk
VadPinchuk / FlutterPlugin.kt
Created Feb 21, 2020
Old approach with static function
View FlutterPlugin.kt
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
val channel = MethodChannel(flutterPluginBinding.binaryMessenger, "flutter_plugin")
channel.setMethodCallHandler(FlutterPlugin())
}
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
}
@VadPinchuk
VadPinchuk / FlutterPlugin.kt
Created Feb 21, 2020
Old approach with static function
View FlutterPlugin.kt
// This static function is optional and equivalent to onAttachedToEngine. It supports the old
// pre-Flutter-1.12 Android projects. You are encouraged to continue supporting
// plugin registration via this function while apps migrate to use the new Android APIs
// post-flutter-1.12 via https://flutter.dev/go/android-project-migration.
//
// It is encouraged to share logic between onAttachedToEngine and registerWith to keep
// them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called
// depending on the user's project. onAttachedToEngine or registerWith must both be defined
// in the same class.w
companion object {
You can’t perform that action at this time.