Selasa, 08 Juni 2021

setup flutter ubuntu 20.04

1. install vs code

sudo snap install code --classic

 

2. install flutter

sudo snap install flutter --classic

 

3. download flutter sdk

flutter sdk-path

 

4. install java 8

sudo apt install openjdk-8-jdk openjdk-8-jre

sudo update-alternatives --config java

 

5. tambahkan di baris terakhir

nano ~/.bashrc

export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"

source ~/.bashrc

 

6. install android studio

sudo snap install android-studio --classic

 

7. set android sdk ke flutter config

flutter config --android-sdk /path/to/android/sdk 

example : flutter config --android-sdk /home/slametdev/android/sdk 


8. running android licenses

flutter doctor --android-licenses

 

ketika command  (flutter doctor --android-licenses)

error:


solusinya:

  1. Uncheck Android SDK command-line Tools (latest)
  2. Check Android SDK command-line Tools 8.0
  3. Click Apply
  4. In Windows, go to “C:\Users\USERNAME\AppData\Local\Android\Sdk\cmdline-tools” and rename the 8.0 folder to “latest”
  5. Run Flutter doctor again.

 

Jumat, 23 April 2021

Cara membuat scrollbar kesamping

#untuk membuat row bisa di scroll

overflow-x:auto; 

#untuk hidden tampilan scroll view

scrollbar-width:none;

#untuk agar scroll view berjalan dengan baik

width:1024px;

Senin, 05 April 2021

Laravel 8 - Cara membuat Chart Grafik (Larapex)

github : https://github.com/ArielMejiaDev/larapex-charts

dokumentasi : https://larapex-charts.netlify.app


1. composer require arielmejiadev/larapex-charts

2. php artisan vendor:publish --tag=larapex-charts-config

3. coding

use ArielMejiaDev\LarapexCharts\LarapexChart;

Route::get('chart', function () {
    $chart = (new LarapexChart)->pieChart()
        ->setTitle('Top 3 scorers of the team.')
        ->setSubtitle('Season 2021.')
        ->addData([40, 50, 30])
        ->setLabels(['Player 7', 'Player 10', 'Player 9']);
    
    return view('chart', compact('chart'));
}); 

Senin, 22 Maret 2021

Get Alamat By Coordinat

 Get Alamat By Coordinat Di Laravel

create app\Helpers\Geocoding.php

<?php

namespace App\Helpers;

class Geocoding
{
protected $api_key;
protected $debug;
protected $callurl = "https://maps.googleapis.com/maps/api/geocode/json";
function __construct($api_key, $debug = 0)
{
$this->api_key = $api_key;
$this->debug = $debug;
}
public function request($url, $parameters)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . "?" . http_build_query($parameters));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
return $result;
}
public function getAddress($latitude, $longitude)
{
$data = [
'latlng' => "$latitude,$longitude",
'key' => $this->api_key
];
$addressData = $this->request($this->callurl, $data);
return (json_decode($addressData)->results[0]->formatted_address);
}
public function getCoordinates($address)
{
$data = [
'address' => $address,
'key' => $this->api_key
];
$addressData = $this->request($this->callurl, $data);
$location = json_decode($addressData)->results[0]->geometry->location;
return [ 'latitude' => $location->lat, 'longitude' => $location->lng];
}
}

tambahkan di file global app\Helpers\Global.php

<?php

function get_address_google($latitude,$longitude){
$geo = new Geocoding('AIzaSyCEqgPSJg-nZ2iJfnEkDY79iRj_rAcQgzg');
$alamat = $geo->getAddress($latitude,$longitude);
return $alamat;
}

cara pemangilan di controller


public function checkout_invoice(Request $request){
$alamat = get_address_google($latitude,$longitude);
return view('frontend.checkout.invoice',compact('data','alamat'));
}


Jumat, 22 Januari 2021

Laravel API Client dengan Guzzle


1. composer require guzzlehttp/guzzle


<?php
    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    use GuzzleHttp\Client;
    use App\Models\Branch;
    class ProductController extends Controller
    {
    public function index()
    {
    $branch = Branch::query();
    $branch->truncate();
    $url = 'https://mnfdev.agrobogautama.co.id/api/getbranch';
    $client = new Client();
    $headers = [
    'Content-Type' => 'application/json',
    'x-api-key' => 'xTYuaskl76510!#$%Zhyuulattr6!',
    ];
    $data = '{}';
    $options = [
    'body' => $data,
    'headers' => $headers,
    ];
    $response = $client->request('get', $url, $options);
    $res = json_decode($response->getBody());
    $data = [];
    $res = $res->result->data;
    foreach($res as $key => $item){
    $data[] = [
    "branch_id"=> $item->branch_id,
    "branch_name"=> $item->branch_name,
    "branch_latitude"=> $item->branch_latitude,
    "branch_longitude"=> $item->branch_longitude,
    "company_id"=> $item->company_id,
    "company_name"=> $item->company_name,
    "region_id"=> $item->region_id,
    "region_name"=> $item->region_name
    ];
    }
    $jd = count($res);
    $chunk = array_chunk($data,$jd);
    foreach($chunk as $d){
    Branch::insert($d);
    }
        }
    }


Senin, 18 Januari 2021

Laravel integrasi dengan midtrans

 Laravel integrasi dengan midtrans

1. composer require midtrans/midtrans-php

2. composer dump-autoload

3. php artisan make:controller MidtransController -r

edit di bagian function index() jadi seperti di bawah.

public function index()
{
// Set your Merchant Server Key
\Midtrans\Config::$serverKey = 'SB-Mid-server-feM6Qc7DQ4tLnsJO_IyhlN2P';
// Set to Development/Sandbox Environment (default). Set to true for Production Environment (accept real transaction).
\Midtrans\Config::$isProduction = false;
// Set sanitization on (default)
\Midtrans\Config::$isSanitized = true;
// Set 3DS transaction for credit card to true
\Midtrans\Config::$is3ds = true;
$params = array(
'transaction_details' => array(
'order_id' => rand(),
'gross_amount' => 10000,
)
);
$snapToken = \Midtrans\Snap::getSnapToken($params);
return view('midtrans',compact('snapToken'));
}

4. buat file midtrans.blade.php di folder resource/view

isi dengan kode di bawah

<html>
<body>
<button id="pay-button">Pay!</button>
<pre><div id="result-json">JSON result will appear here after payment:<br></div></pre>

<!-- TODO: Remove ".sandbox" from script src URL for production environment. Also input your client key in "data-client-key" -->
<script src="https://app.sandbox.midtrans.com/snap/snap.js" data-client-key="<Set your ClientKey here>"></script>
<script type="text/javascript">
document.getElementById('pay-button').onclick = function(){
// SnapToken acquired from previous step
snap.pay('<?=$snapToken?>', {
// Optional
onSuccess: function(result){
/* You may add your own js here, this is just example */ document.getElementById('result-json').innerHTML += JSON.stringify(result, null, 2);
},
// Optional
onPending: function(result){
/* You may add your own js here, this is just example */ document.getElementById('result-json').innerHTML += JSON.stringify(result, null, 2);
},
// Optional
onError: function(result){
/* You may add your own js here, this is just example */ document.getElementById('result-json').innerHTML += JSON.stringify(result, null, 2);
}
});
};
</script>
</body>
</html>

5. setting route web.php


Route::resource('midtrans','MidtransController');

6. php artisan serve

7. akses localhost:8000


oke


Rabu, 13 Januari 2021

Request Ajax Secara Interval


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<div id="data-id"></div>
<script>
function fetchdata(){
    $.ajax({
        url: "{{ route('user.index') }}",
        type: 'get',
        success: function(data){
            // eksekusi kode di sini
            // alert(data);
            $('#data-id').html(data) // ini contohnya
        },
        complete:function(data){
            setTimeout(fetchdata,100);
        }
    });
}

$(document).ready(function(){
    setTimeout(fetchdata,1000);
});
</script>

create project flutter with getx

Get CLI adalah alat yang sangat berguna untuk mempercepat pengembangan aplikasi Flutter dengan memanfaatkan arsitektur GetX . Berikut adala...