This is a quick guide to Kotlin programming language. The previous part of this guide is here
#Object Oriented
fun main(args : Array<String>) {
class local (val x : Int)
val y = local(10)
println("${y.x}")
using System.Text.RegularExpressions; | |
public static class StringExtensions | |
{ | |
// remove double spaces | |
public static string RemoveExtraSpaces(this string sender, bool trimEnd = false) | |
{ | |
const RegexOptions options = RegexOptions.None; | |
var regex = new Regex("[ ]{2,}", options); | |
var result = regex.Replace(sender, " "); |
const totalTypes = { | |
VIEWS: 2, | |
READS: 3, | |
FANS: 5 | |
}; | |
const getTotal = tableColumn => | |
[ | |
...document.querySelectorAll( | |
`td:nth-child(${tableColumn}) > span.sortableTable-number` |
This is a quick guide to Kotlin programming language. The previous part of this guide is here
#Object Oriented
fun main(args : Array<String>) {
class local (val x : Int)
val y = local(10)
println("${y.x}")
#Intro
Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3
Kotlin project website is at kotlin.jetbrains.org.
All the codes here can be copied and run on Kotlin online editor.
Let's get started.
import 'package:flutter/material.dart'; | |
import 'package:get/get.dart'; | |
import 'package:get_storage/get_storage.dart'; | |
void main() async { | |
WidgetsFlutterBinding.ensureInitialized(); | |
await initialConfig(); | |
final storage = Get.find<StorageService>(); |
class MainScreen extends StatefulWidget { | |
State createState() => MainScreenState(); | |
} | |
class MainScreenState extends State<MainScreen> { | |
var _androidAppRetain = MethodChannel("android_app_retain"); | |
@override | |
void initState() { | |
super.initState(); |
class MainActivity : FlutterActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
GeneratedPluginRegistrant.registerWith(this) | |
MethodChannel(flutterView, "android_app_retain").apply { | |
setMethodCallHandler { method, result -> | |
if (method.method == "sendToBackground") { | |
moveTaskToBack(true) | |
} |
private fun createNativeView(handle: Long) { | |
FlutterMain.ensureInitializationComplete(this, arrayOf()) | |
val nativeView = FlutterNativeView(this, true) | |
val callback = FlutterCallbackInformation.lookupCallbackInformation(handle) | |
nativeView.runFromBundle(FlutterRunArguments().apply { | |
bundlePath = FlutterMain.findAppBundlePath(this@Service) | |
libraryPath = callback.callbackLibraryPath | |
entrypoint = callback.callbackName |
import 'dart:async'; | |
import 'package:flutter/cupertino.dart'; | |
import 'package:hooks_riverpod/hooks_riverpod.dart'; | |
import 'package:location/location.dart'; | |
class PersonLocationProvider extends ChangeNotifier { | |
Location _location = new Location(); | |
PermissionStatus _permissionGranted; | |
StreamController<LocationData> currentLocation = StreamController.broadcast(); |
import 'dart:io'; | |
import 'package:flutter/material.dart'; | |
import 'package:google_maps_flutter/google_maps_flutter.dart'; | |
import 'package:provider/provider.dart'; | |
import 'package:clippy_flutter/clippy_flutter.dart'; | |
void main() { | |
runApp( | |
ChangeNotifierProvider( |