<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ogak Dev on Medium]]></title>
        <description><![CDATA[Stories by Ogak Dev on Medium]]></description>
        <link>https://medium.com/@ogak?source=rss-37cb323d24b1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*HLrB5WsdtUC9mREdjjso9g.jpeg</url>
            <title>Stories by Ogak Dev on Medium</title>
            <link>https://medium.com/@ogak?source=rss-37cb323d24b1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 02:30:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ogak/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Secure API Key Handling in Android: What Actually Works]]></title>
            <link>https://medium.com/@ogak/secure-api-key-handling-in-android-what-actually-works-c80286be7e52?source=rss-37cb323d24b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c80286be7e52</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Ogak Dev]]></dc:creator>
            <pubDate>Mon, 12 Jan 2026 04:03:51 GMT</pubDate>
            <atom:updated>2026-01-12T04:03:51.425Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B-DdOfUDsMVfyFNWeNWsHg.jpeg" /><figcaption>images from: <a href="https://nordicapis.com/wp-content/uploads/9-Signs-Youre-Doing-API-Security-Wrong-1024x576.jpg">https://nordicapis.com/wp-content/uploads/9-Signs-Youre-Doing-API-Security-Wrong-1024x576.jpg</a></figcaption></figure><p>Your API key is a secrets and you need to keep it secure, in Web development you can use tools like <em>.env </em>by creating environment file put your key in there and added it to <em>.gitignore</em> list (if you’re working in public repo git). How about Android or Flutter development?? Let’s follow this step by step:</p><blockquote>Before following this step this project is using Kotlis DSL version <em>.kts</em></blockquote><ol><li>Create secrets file<br>Same as <em>.env</em> file in web development. Create a file secrets.propertiesin android folder. Put your Map key in there: GOOGLE_MAP_API_KEY=YOUR-API-KEY if you seems the variable name is too long you can adjust by your needs.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/1*tls1VhkIRlH3RyIX5YBqXA.png" /><figcaption>secrets.properties</figcaption></figure><blockquote>IMPORTANT: Make sure the secrets file its added to .gitignore list</blockquote><p>2. Add Plugin <em>secret-gradle-plugin <br></em>This plugin is developed by Google, while this article is written its version 2.0.1. In your settings.gradle.ktsadd this</p><pre>id(“com.google.android.libraries.mapsplatform.secrets-gradle-plugin”) version “2.0.1” apply false </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*rHp4oG9R1zEdPwPpPkC6XQ.png" /><figcaption>settings.gradle.kts</figcaption></figure><p>in plugins block. Next in your app level <em>build.gradle.kts. </em>Add this<em> </em>in plugin block</p><pre>id(“com.google.android.libraries.mapsplatform.secrets-gradle-plugin”)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*4wv0cQ28vChP7bj7mqRZ9Q.png" /><figcaption>build.gradle.kts</figcaption></figure><p>3. Connect plugin with the secret file</p><p>In gradle.build.kts app level create secrets block. Create a variable propertiesFileName add value with name file that created in first step.</p><pre>secrets {<br>    // To add your Maps API key to this project:<br>    // 1. If the secrets.properties file does not exist, create it in the same folder as the local.properties file.<br>    // 2. Add this line, where YOUR_API_KEY is your API key:<br>    //        MAPS_API_KEY=YOUR_API_KEY<br>    propertiesFileName = &quot;secrets.properties&quot;<br><br>    // A properties file containing default secret values. This file can be<br>    // checked in version control.<br>    defaultPropertiesFileName = &quot;local.defaults.properties&quot;<br>}</pre><p>And Everything is setup. Last step we can call the API key variable in AndroidManifest.xml</p><pre>... PERMISSIONS ...<br>&lt;application<br>        android:label=&quot;YOUR_APP_NAME&quot;<br>        android:name=&quot;${applicationName}&quot;<br>        android:icon=&quot;@mipmap/launcher_icon&quot;&gt;<br>        &lt;!-- API KEY VARIABLE FROM SECRETS HERE --&gt;<br>        &lt;meta-data android:name=&quot;com.google.android.geo.API_KEY&quot;<br>            android:value=&quot;${GOOGLE_MAP_API_KEY}&quot;/&gt; <br>        &lt;!-- API KEY VARIABLE FROM SECRETS HERE --&gt;<br>     <br>        &lt;activity<br>            android:name=&quot;.MainActivity&quot;<br>            android:exported=&quot;true&quot;<br>            android:launchMode=&quot;singleTop&quot;<br>            android:taskAffinity=&quot;&quot;<br>            android:theme=&quot;@style/LaunchTheme&quot;<br>            android:configChanges=&quot;orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode&quot;<br>            android:hardwareAccelerated=&quot;true&quot;<br>            android:windowSoftInputMode=&quot;adjustResize&quot;&gt;<br>....</pre><p>Thats it. For more information go to plugin repo <a href="https://github.com/google/secrets-gradle-plugin">secrets-gradle-plugin</a>.</p><p>Don’t ever think its secure, there’s no such thing as a <em>perfectly secure</em> API key on the client side — especially on Android. If someone is motivated enough, they can reverse-engineer almost anything. At least we can do something to protect our project.</p><p>The goal is simple: <strong>raise the cost of attack</strong>. Make it annoying, time-consuming, and not worth the effort.<br>If you’re building a small app, don’t overthink it. If you’re building something serious, invest in the boring but correct solutions. Security is rarely about fancy tricks — it’s about good decisions, made consistently.</p><p>Hopefully this article helps you secure your API Key especially in Android World. Keep your secrets unnoticed 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c80286be7e52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Method channel flutter]]></title>
            <link>https://medium.com/@ogak/method-channel-flutter-2c23ae702e29?source=rss-37cb323d24b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c23ae702e29</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[method-channel]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Ogak Dev]]></dc:creator>
            <pubDate>Tue, 28 Jan 2025 12:59:05 GMT</pubDate>
            <atom:updated>2025-01-28T12:59:05.831Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article we will try to use method channel to call a specific method from native (iOS and Android).</p><p>Sharing data (Android) or Share sheet (iOS). This is ability to communicate and integrate with other app, in this article we will send simple text to other app.</p><p>Here is the preview</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FKa4Y1TqLCMhprRlADi%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FKa4Y1TqLCMhprRlADi&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExdHhjMXh0dWN5YzBsenVqeHV4MjRpamh3MmJ5NmRrbmxrcGM1dDNlbyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FKa4Y1TqLCMhprRlADi%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="344" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2994afe8aeb25bdb7cfa650502d40f6/href">https://medium.com/media/c2994afe8aeb25bdb7cfa650502d40f6/href</a></iframe><p>Both are using native code to access the share sheet.</p><p>Here is the code flow illustration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*s-NLcu6uWpfGp_GyafQiBw.png" /></figure><p>Let’s jump to the code.</p><p>In this case we will share a phone number to other apps, and display share sheet so the user can select which app to share.</p><blockquote>Note: some app may accept link or specific type data.</blockquote><ol><li><strong>Create a method to send a text to host.</strong></li></ol><p>create a variable <em>_channel</em> and define method channel name</p><pre>static const _channel =<br>      MethodChannel(&#39;com.example.method_channel_sample/share_sheet&#39;);</pre><p>create <em>shareContact</em> method with parameter phoneNumber with type data String, “<em>shareContact</em>” will used as method call in host. The value will be in JSON format with key “<em>message</em>”.</p><pre>Future&lt;void&gt; shareContact(String phoneNumber) async {<br>    try {<br>      await _channel.invokeMethod(&#39;shareContact&#39;, {&#39;message&#39;: phoneNumber});<br>    } on PlatformException catch (e) {<br>      log(&quot;Failed to share contact: ${e.message}&quot;, name: &#39;shareContact Method&#39;);<br>    }<br>  }</pre><p>Call the function in your button or where it needed.</p><pre>IconButton(<br>  icon: Icon(Icons.share),<br>  onPressed: () {<br>    shareContact(item.phoneNumber);<br>  },<br>),</pre><p>That’s it.</p><p><strong>Setup Android method channel</strong></p><blockquote>It’s recommended to use Android Studio to edit the kotlin/java code and Xcode to edit swift/obj-c code.</blockquote><p>Open <em>MainActivity.kt</em>, you can find it in the root tree of android folder and then call the share sheet if the call.method is “shareContact”.</p><pre>import android.content.Intent<br>import androidx.annotation.NonNull<br>import io.flutter.embedding.android.FlutterActivity<br>import io.flutter.embedding.engine.FlutterEngine<br>import io.flutter.plugin.common.MethodChannel<br><br><br>class MainActivity: FlutterActivity() {<br>  private val channel = &quot;com.example.method_channel_sample/share_sheet&quot;<br><br>  override fun configureFlutterEngine(flutterEngine: FlutterEngine) {<br>    MethodChannel(flutterEngine.dartExecutor.binaryMessenger, channel).setMethodCallHandler {<br>      call, result -&gt;<br>      if (call.method == &quot;shareContact&quot;) {<br>          val message = call.argument&lt;String&gt;(&quot;message&quot;)<br>          shareSheet(message.toString())<br>          println(&quot;Received message: $message&quot;)<br>          result.success(null)<br>      } else {<br>          result.notImplemented()<br>      }<br>    }<br>  }<br><br>  private fun shareSheet(message: String) {<br>    val sendIntent: Intent = Intent().apply {<br>      action = Intent.ACTION_SEND<br>      putExtra(Intent.EXTRA_TEXT, message)<br>      type = &quot;text/plain&quot;<br>    }<br>    val shareIntent = Intent.createChooser(sendIntent, null)<br>    startActivity(shareIntent)<br>  }<br>}</pre><p>Thats it. Next setup the iOS.</p><p><strong>Setup iOS method channel</strong></p><p>The implementation is same as Android what makes it difference is the programming language. Find <em>AppDelegate.swift</em> in iOS folder and then implement method.</p><pre>import Flutter<br>import UIKit<br><br>@main<br>@objc class AppDelegate: FlutterAppDelegate {<br>  override func application(<br>    _ application: UIApplication,<br>    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?<br>  ) -&gt; Bool {<br>    GeneratedPluginRegistrant.register(with: self)<br>      <br>      let appId = &quot;com.example.method_channel/share_sheet&quot;<br>      <br>      let controller = window?.rootViewController as! FlutterViewController<br>      <br>      let channel = FlutterMethodChannel(name: &quot;com.example.method_channel_sample/share_sheet&quot;, binaryMessenger: controller.binaryMessenger)<br>      <br>      channel.setMethodCallHandler { (call: FlutterMethodCall, result: @escaping FlutterResult) in<br>          if call.method == &quot;shareContact&quot; {<br>              if let args = call.arguments as? [String: Any], let message = args[&quot;message&quot;] as? String {<br>                  self.showShareSheet(message: message)<br>                  print(&quot;Received message: \(message)&quot;)<br>                  <br>                  result(nil)<br>              }<br>          } else {<br>              result(FlutterMethodNotImplemented)<br>          }<br>      }<br>    return super.application(application, didFinishLaunchingWithOptions: launchOptions)<br>  }<br>    <br>    private func showShareSheet(message: String) {<br>        DispatchQueue.main.async {<br>            if let rootVC = self.window.rootViewController {<br>                let av = UIActivityViewController(activityItems: [message], applicationActivities: nil)<br>                rootVC.present(av, animated: true)<br>            }<br>        }<br>    }<br><br>}</pre><p>Thats it. Try build and run your app in both Android and iOS.</p><p>if the iOS has error you may delete your app first and then <em>flutter clean.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c23ae702e29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[In-app update android using flutter]]></title>
            <link>https://medium.com/@ogak/in-app-update-android-using-flutter-d7cca6729517?source=rss-37cb323d24b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7cca6729517</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[in-app-update]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Ogak Dev]]></dc:creator>
            <pubDate>Sun, 26 Jan 2025 15:42:10 GMT</pubDate>
            <atom:updated>2025-01-26T15:42:10.043Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0pF_D-DYFrgO-HBfXLz1sA.png" /></figure><p>In order to keep users up-to-date with the latest version of your app, you can add I<em>n-App update</em> feature to allow mobile app update themselves while they are running.</p><p>There are 2 type in-app update.</p><ol><li>Flexible update</li><li>Immediate update (see the picture below)</li></ol><p>For more information, please read <a href="https://developer.android.com/guide/playcore/in-app-updates">developer android documentation</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-j-eITXGjVn82BkcQdZS4w.png" /><figcaption>Immediate update</figcaption></figure><p>This feature now can be added in flutter. You can use ready to use package like <a href="https://pub.dev/packages/in_app_update">In app update</a>.</p><p><strong>Coding</strong></p><p>The code is not complicated, checkUpdate() function is the code you need. Below code is my example.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/384a833720b14f9796c091b870515c0a/href">https://medium.com/media/384a833720b14f9796c091b870515c0a/href</a></iframe><p>I call InAppUpdateProvider in login page and home page. If there is an update it will call InAppUpdate.performImmediateUpdate() method. Update dialog will be appeared.</p><p><strong>To test:</strong> you must release your app (recommend as internal test) first in playstore with above code implemented. For example:</p><ol><li>Create internal test with version 1.0.0</li><li>Download the version 1.0.0 from playstore, the InAppUpdate will not work if the app is not from Playstore.</li><li>Create new internal test again with increment version and build number 1.0.1</li></ol><blockquote>Unlearn what you’ve learn</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7cca6729517" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter with Riverpod: Play with camera]]></title>
            <link>https://medium.com/@ogak/flutter-with-riverpod-play-with-camera-b7aa23776283?source=rss-37cb323d24b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7aa23776283</guid>
            <dc:creator><![CDATA[Ogak Dev]]></dc:creator>
            <pubDate>Sun, 26 May 2024 15:34:40 GMT</pubDate>
            <atom:updated>2024-05-26T15:34:40.447Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vgZKntjFXw8GvD3fAOu-Iw.jpeg" /></figure><p>Camera is one of smartphone hardware resource to capture picture and video. I want to share how I create camera feature in my app, in this article I use these packages.</p><ol><li><a href="https://pub.dev/packages/camera">Camera</a></li><li>Hooks Riverpod (or just riverpod), Riverpod Generator, Riverpod annotation (State management)</li><li>Build Runner</li><li>Permission handler</li><li>Path provider (Directory management)</li></ol><p>You may familiar with one of those packages.</p><p>After adding all of those packages, first we will setup the android permission</p><pre>&lt;uses-permission android:name=&quot;android.permission.CAMERA&quot; /&gt;<br>&lt;uses-feature android:name=&quot;android.hardware.camera&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;</pre><p>And Camera package may required <em>compileSdkVersion 34</em>, set it to your <em>app/build.gradle </em>in<em> defaultConfig {…}.</em></p><p>next, we will create our <em>camera provider</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/857a47472f51868cc13e05e096952dff/href">https://medium.com/media/857a47472f51868cc13e05e096952dff/href</a></iframe><p><em>cameraPermission </em>is the function for get the current camera permission, if not yet granted the dialog permission will appear.</p><p><em>cameraController </em>will check permission first, after the permission is granted, the next step is initialize camera and return the camera controller. This controller will be use to control camera such as take a picture, change back or front camera and etc.</p><p>You can see at camera controller, I set the <em>cameraDescription[0]</em> (which mean the back camera and [1] is the front) with the resolution is high.</p><p>Next is create our camera UI. You can use stateless or stateful widget, since riverpod is <em>autodispose</em> stateless is enough.</p><p>First, call cameraController like this</p><pre>Widget build(BuildContext context, WidgetRef ref) {<br>final camera = ref.watch(cameraControllerProvider);<br><br>return camera.when(<br>        data: (controller) {<br>          if (controller == null) {<br>            return Container();<br>          }<br>          return CameraPreview(<br>              controller<br>              );<br>        },<br>        error: (err, st) =&gt; const Center(child: Text(err.toString()),<br>        loading: () =&gt; const Center(<br>              child: CircularProgressIndicator(),<br>            ),<br>   );<br>}</pre><p>If you run your app it will ask for permission and then display the camera preview.</p><p>Next, we will add camera button, we can use Stack widget to add button.</p><pre>CameraPreview(<br>              controller,<br>              child: Stack(<br>                children: [<br>                  Positioned(<br>                      bottom: 0,<br>                      right: 0,<br>                      child: IconButton(<br>                          onPressed: () {<br>                            /// add the button function to switch camera<br>                          },<br>                          icon: const Icon(<br>                            Icons.cameraswitch,<br>                            color: Colors.white,<br>                          ))),<br>                   Positioned(<br>                   bottom: 0,<br>                   left: 0,<br>                    child: IconButton(<br>                        iconSize: 45,<br>                        onPressed: () {<br>                         /// add the function to take a picture<br>                        },<br>                        icon: const Icon(<br>                          Icons.camera,<br>                          color: Colors.amber,<br>                        )),<br>                  )<br>                ],<br>              ),<br>            ),</pre><p>Next we will create a function for our camera switch camera and take picture.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da7a29b1c938126d320f1c28ac1819ac/href">https://medium.com/media/da7a29b1c938126d320f1c28ac1819ac/href</a></iframe><p>the camera state is a class that return void, so we can call the function with camera controller as parameter.</p><p><em>switchCamera </em>this function is to set camera front or back.</p><p><em>takePicture </em>will return the file with type data <em>XFile </em>which is our picture. It will be saved in cache, We dont directly save it into our folder because we will display the preview first.</p><p><em>saveToGallery </em>this function is used to save our picture to defined path, in this case i use path storage/emulated/0/DCIM/Camera which is in internal storage. The file will read as bytes and save it in bytes (Uint8List).</p><p>and call those function into our buttons.</p><pre>Positioned(<br>    bottom: 0,<br>    right: 0,<br>    child: IconButton(<br>            onPressed: () {<br>              /// add the button function to switch camera<br>                   ref<br>                      .read(cameraStateProvider.notifier)<br>                      .switchCamera(controller);<br>                },<br>            icon: const Icon(<br>                Icons.cameraswitch,<br>                color: Colors.white,<br>              ))),</pre><pre>Positioned(<br>   bottom: 0,<br>   left: 0,<br>    child: IconButton(<br>        iconSize: 45,<br>        onPressed: () {<br>         /// add the function to take a picture<br>          ref<br>            .read(cameraStateProvider.notifier)<br>            .takePicture(controller);<br>        },<br>        icon: const Icon(<br>          Icons.camera,<br>          color: Colors.amber,<br>        )),<br>  )</pre><p>Furthermore, we need to create a preview after taking a picture.</p><p>Create new stateless or stateful widget with XFile parameter.</p><pre>class PicturePreviewWidget extends HookConsumerWidget {<br>  final XFile? pictureFile;<br>  const PicturePreviewWidget({super.key, this.pictureFile});<br>  @override<br>  Widget build(BuildContext context, WidgetRef ref) {<br>    if (pictureFile == null) {<br>      return const SizedBox.shrink();<br>    }<br>    return Stack(<br>          children: [<br>            SizedBox(<br>              height: MediaQuery.of(context).size.height,<br>              width: MediaQuery.of(context).size.width,<br>              child: Image.file(<br>                File(pictureFile!.path),<br>                fit: BoxFit.cover,<br>              ),<br>            ),<br>            Positioned(<br>              bottom: 0,<br>              left: 0,<br>              right: 0,<br>              child: Padding(<br>                padding: const EdgeInsets.all(16.0),<br>                child: Row(<br>                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,<br>                  children: [<br>                    Flexible(<br>                      child: SizedBox(<br>                        width: MediaQuery.of(context).size.width,<br>                        child: ElevatedButton.icon(<br>                          onPressed: () {<br>                            Navigator.of(context).pop();<br>                          },<br>                          icon: const Icon(Icons.delete),<br>                          label: const Text(&quot;Discard&quot;),<br>                        ),<br>                      ),<br>                    ),<br>                    const SizedBox(width: 16),<br>                    Flexible(<br>                      child: SizedBox(<br>                        width: MediaQuery.of(context).size.width,<br>                        child: ElevatedButton.icon(<br>                          onPressed: () {<br>                            ref<br>                                .read(cameraStateProvider.notifier)<br>                                .saveToGallery(pictureFile)<br>                                .then((val) {<br>                              Navigator.of(context).pop();<br>                            });<br>                            <br>                          },<br>                          icon: const Icon(Icons.save),<br>                          label: const Text(&quot;Save Preview&quot;),<br>                        ),<br>                      ),<br>                    ),<br>                  ],<br>                ),<br>              ),<br>            ),<br>          ],<br>        ),<br>}</pre><p><em>Image.file </em>is the widget to display image from path, wrap it with Stack to add button on top of preview picture.</p><pre>ref<br>  .read(cameraStateProvider.notifier)<br>  .saveToGallery(pictureFile)<br>  .then((val) {<br>Navigator.of(context).pop();<br>});</pre><p>in save button we call saveToGallery function, if success it will pop and return to camera again.</p><p>Next we update take picture button</p><pre>ref<br>.read(cameraStateProvider.notifier)<br>.takePicture(controller)<br>.then((value) {<br>  if (value != null) {<br>    Navigator.of(context)<br>        .push(MaterialPageRoute(builder: (context) {<br>      return PicturePreviewWidget(pictureFile: value);<br>    }));<br>  }<br>});</pre><p>call <em>then(…), </em>if the value is not null it will navigate to <em>PicturePreviewWidget.</em></p><p>Here is the result</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FFqqu5sH3F83aFsJS6W%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExeTFwYzlmZGx0MXRvbzNqaGJ5bDAycXhkODY4bWp1ZGd5eW95cWZxdyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FFqqu5sH3F83aFsJS6W%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExZTkwdXVyeTBtYnU5YnQ3enNkb3EyMXVxeXA2c2E3eXRzOW5oNHJidCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FFqqu5sH3F83aFsJS6W%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/f850fce2fde835b7581721824c1d8c1f/href">https://medium.com/media/f850fce2fde835b7581721824c1d8c1f/href</a></iframe><p>Bye.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7aa23776283" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gmail List Select Styles in Flutter]]></title>
            <link>https://medium.com/@ogak/gmail-list-select-styles-in-flutter-f81545bc7140?source=rss-37cb323d24b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/f81545bc7140</guid>
            <category><![CDATA[lists]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Ogak Dev]]></dc:creator>
            <pubDate>Sun, 03 Sep 2023 15:32:41 GMT</pubDate>
            <atom:updated>2023-09-03T15:32:41.865Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7evqwHamVo5TWA0ZZrDhCQ.jpeg" /></figure><p>Flutter has revolutionized the world of mobile app development, providing developers with a powerful framework to create stunning user interfaces. When it comes to crafting lists with selectable items, Flutter offers a range of options that cater to diverse design preferences.</p><p>Whether you are an experienced Flutter developer seeking new ideas or a beginner eager to learn, this article will equip you with the knowledge and inspiration to enhance your app’s user experience.</p><p>We will create list select UI/UX like Gmail have. Here is the preview:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FVppYU2gJN0KsJtCQ9n%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FVppYU2gJN0KsJtCQ9n&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExcHFmaTNjN25obnZkYmNhOWszdTdwbjdmbndubmg4NXp0NHg2ZWt0NSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FVppYU2gJN0KsJtCQ9n%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="561" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc9ddfde2f9bedaa64eeff0e0cb19ca4/href">https://medium.com/media/bc9ddfde2f9bedaa64eeff0e0cb19ca4/href</a></iframe><p>First, create or add your list data, here I have list of fruits:</p><pre>List&lt;String&gt; listData = [<br>    &quot;Apple&quot;,<br>    &quot;Banana&quot;,<br>    &quot;Cherries&quot;,<br>    &quot;Durian&quot;,<br>    &quot;Fig&quot;,<br>    &quot;Grapefruit&quot;,<br>    &quot;Honeydew&quot;,<br>    &quot;Jackfruit&quot;,<br>    &quot;Kiwi&quot;,<br>    &quot;Lemon&quot;,<br>    &quot;Mango&quot;,<br>    &quot;Pineapple&quot;,<br>    &quot;Quince&quot;,<br>    &quot;Raspberry&quot;,<br>    &quot;Starfruit&quot;,<br>    &quot;Ugli fruit&quot;,<br>    &quot;Watermelon&quot;,<br>    &quot;Zucchini&quot;<br>  ];</pre><p>Then , create empty List string with type data same as listData to store the selected fruit.</p><pre>List&lt;String&gt; _selected = [];</pre><p>Next, I am using ListView.builder to display the data:</p><pre>ListView.builder(<br>        itemCount: listData.length, // length of listData<br>        itemBuilder: (context, idx) {<br>          final data = listData[idx]; // shorter variable name<br>          return Padding(<br>            padding: const EdgeInsets.all(8.0),<br>            child: ListTile(<br>              contentPadding:<br>                  const EdgeInsets.symmetric(horizontal: 8, vertical: 2),<br>              shape: RoundedRectangleBorder(<br>                  borderRadius: BorderRadius.circular(12)),<br>              selected: _selected.contains(data),<br>              selectedTileColor: Colors.amber,<br>              onTap: () {<br>                // check if _selected has data<br>                if (_selected.contains(data)) {<br>                  // remove if true<br>                  setState(() {<br>                    _selected.remove(data);<br>                  });<br>                } else {<br>                  setState(() {<br>                    // add<br>                    _selected.add(data);<br>                  });<br>                }<br>              },<br>              leading: _selected.contains(data)<br>                  ? const CircleAvatar(<br>                      child: Icon(Icons.done),<br>                    )<br>                  : CircleAvatar(<br>                      child: Text(data[0].toUpperCase()),<br>                    ),<br>              title: Text(data),<br>            ),<br>          );<br>        },<br>      ),</pre><p>Inside ListView.builder, I use <strong>ListTile widget </strong>to display every single data with paramater:<br><strong>selected: </strong>To check if data is being selected.<br><strong>selectedTileColor: </strong>If <strong>selected</strong> true change the tile color.<br><strong>leading: </strong>is an AvatarCircle widget which is display the first character of data if not selected and icon done if selected.<br><strong>title</strong>: item name.<br><strong>onTap</strong>: Add/Remove item from <strong>_selected</strong>.</p><p>Furthermore, In AppBar, I will change its state to display the selected count add action button.</p><pre>appBar: _selected.isEmpty<br>          ? AppBar(<br>              backgroundColor: Theme.of(context).colorScheme.inversePrimary,<br>              title: Text(widget.title),<br>            )<br>          : AppBar(<br>              title: Text(&quot;Selected ${_selected.length}&quot;),<br>              actions: [<br>                IconButton(<br>                  onPressed: () {<br>                    /// Do something with selected item<br>                  },<br>                  icon: const Icon(Icons.delete),<br>                )<br>              ],<br>            ),</pre><p>Thats it, Run your app. <br>Full code: <a href="https://dartpad.dev/49bde0c1ed780decc902f3d4d06d8f0c">https://dartpad.dev/49bde0c1ed780decc902f3d4d06d8f0c</a>?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f81545bc7140" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implement Logger Flutter]]></title>
            <link>https://medium.com/@ogak/implement-logger-flutter-e6cd7897e211?source=rss-37cb323d24b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6cd7897e211</guid>
            <category><![CDATA[logger]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[singleton-class]]></category>
            <dc:creator><![CDATA[Ogak Dev]]></dc:creator>
            <pubDate>Sun, 25 Jun 2023 06:27:35 GMT</pubDate>
            <atom:updated>2023-06-25T06:27:35.347Z</atom:updated>
            <content:encoded><![CDATA[<p>In programming, a log is a record of events, messages, or actions that occur within a software application, system, or process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LDOCgUU8jNl87aUvac8ofw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/es/@roketpik?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Artur Shamsutdinov</a> on <a href="https://unsplash.com/photos/Gll-v69L8iA?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Sometimes you need the log in terminal to see what happen with your code/function it is executed, has an error, or working just fine.</p><p>This how I implements log in flutter using Logger 1.4.0 package.</p><p><em>Wait a minute, Why I need logger ? Flutter/Dart has default print, because Logger are Small, easy to use and extensible logger which prints beautiful logs.</em></p><p>Create a class file, here i give it name <em>simple_log.dart</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5be521eabff3185b35699cf1950c4148/href">https://medium.com/media/5be521eabff3185b35699cf1950c4148/href</a></iframe><p>You can choose the display of your log, by editing the PrettyPrinter() options.</p><p>Simply call applog, don’t forget to import simple_log.dart and logger package.</p><pre>applog(“Your message”, Level.error) </pre><p>If you left level blank, The default level is <em>Level.info</em> will be used, you can change this based on your need.</p><p>For detail information about level and more about logger you can go to <a href="https://pub.dev/packages/logger">logger documentation in pub.dev</a>.</p><p>Example:</p><pre>class MainUI extends ConsumerWidget {<br>  const MainUI({super.key});<br><br>  @override<br>  Widget build(BuildContext context, WidgetRef ref) {<br>    applog(&quot;App build started. Verbose&quot;, level: Level.verbose);<br>    applog(&quot;This is info&quot;, level: Level.info);<br>    applog(&quot;This is error&quot;, level: Level.error);<br>    applog(&quot;This is warning&quot;, level: Level.warning);<br>    applog(&quot;This is debug&quot;, level: Level.debug);<br>    applog(&quot;This is you are in serious danger!&quot;, level: Level.wtf);<br>         <br>    return Scaffold(<br>      appBar: AppBar(<br>        backgroundColor: Colors.indigo,<br>        title: const Text(&quot;My Apps&quot;),<br>      ),<br>      body: const Center(<br>        child: Text(&quot;Logger Flutter&quot;),<br>      ),<br>    );<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XJ7vCBTSn9fCYUOJO2To_Q.png" /><figcaption>In terminal will be display like above picture.</figcaption></figure><p>This is more clear, easy to read, and beautiful printed logs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6cd7897e211" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Signature with Flutter + Syncfusion SignaturePad]]></title>
            <link>https://medium.com/@ogak/building-signature-with-flutter-syncfusion-signaturepad-a47642708830?source=rss-37cb323d24b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a47642708830</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[syncfusion]]></category>
            <dc:creator><![CDATA[Ogak Dev]]></dc:creator>
            <pubDate>Fri, 03 Mar 2023 14:18:35 GMT</pubDate>
            <atom:updated>2023-03-03T14:26:01.134Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*HEyhZ59eJqRuUmhfOnL_dA.jpeg" /></figure><p>Why Syncfusion? because it supports many platforms and frameworks.</p><p>We will create a simple signature input with the <a href="https://pub.dev/packages/syncfusion_flutter_signaturepad">syncfusion_flutter_signaturepad</a> package. Our project goal are to get the signature input and display the inputted signature.</p><p><strong>Let’s Get Started!</strong></p><p>Create a new Flutter project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*fdCuLA4Ttd7J--_2we76_w.png" /><figcaption>This is my project structure</figcaption></figure><p>Add the signature package in pubspec.yaml,</p><pre>flutter pub add syncfusion_flutter_signaturepad</pre><p>optional, you can add state management like riverpod or use setState instead. (In this article I am using Riverpod 😀).</p><p>On the main page, don&#39;t forget to wrap the widget&#39;s root (MaterialApp) with ProviderScope.</p><pre>...<br>return ProviderScope(<br>      child: MaterialApp(<br>        title: &#39;Flutter Demo&#39;,<br>        theme: ThemeData(<br>          primarySwatch: Colors.blue,<br>        ),<br>        home: const SignaturePage(),<br>      ),<br>    );<br>...</pre><p>Create signature_page extends ConsumerWidget to help obtain state.</p><blockquote>ConsumerWidget is similar to Stateless, but have extra parameter WidgetRef.</blockquote><pre>class SignaturePage extends ConsumerWidget {<br>  const SignaturePage({Key? key}) : super(key: key);<br><br>  @override<br>  Widget build(BuildContext context, WidgetRef ref) {<br>    ui.Image mySign;<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: const Text(&quot;Signature&quot;),<br>      ),<br>      body: Column(<br>        children: [<br>          Center(<br>            child: SizedBox(<br>              height: 300,<br>              width: 400,<br>              child: InkWell(<br>                onTap: () {<br>                  showDialog(<br>                      context: context,<br>                      builder: (BuildContext context) {<br>                        return SignaturePadDialog();<br>                      });<br>                },<br>                child: Card(<br>                  child: Column(<br>                    mainAxisAlignment: MainAxisAlignment.center,<br>                    children: [<br>                      Column(<br>                        children: [<br>                          mySign != null<br>                              ? RawImage(<br>                                  image: mySign,<br>                                )<br>                              : const SignaturePlaceholder(),<br>                        ],<br>                      ),<br>                    ],<br>                  ),<br>                ),<br>              ),<br>            ),<br>          ),<br>        ],<br>      ),<br>    );<br>  }<br>}</pre><p>We wrap the Card with Inkwell to add an onPress function to display the signature pad dialog.</p><p>Create a Signature Pad Dialog widget that extends ConsumerWidget to help obtain state.</p><pre>class SignaturePadDialog extends ConsumerWidget {<br>  final GlobalKey&lt;SfSignaturePadState&gt; _signaturePadKey = GlobalKey();<br><br>  SignaturePadDialog({Key? key}) : super(key: key);<br><br>  @override<br>  Widget build(BuildContext context, WidgetRef ref) {<br>    ui.Image? mySignature;<br>    return AlertDialog(<br>      title: const Text(&quot;Sign Dialog&quot;),<br>      content: Container(<br>        height: 250,<br>        width: MediaQuery.of(context).size.width,<br>        decoration: BoxDecoration(<br>          border: Border.all(width: 1, color: Colors.black),<br>        ),<br>        child: SfSignaturePad(<br>          key: _signaturePadKey,<br>          strokeColor: Colors.black,<br>          backgroundColor: Colors.white,<br>          minimumStrokeWidth: 4,<br>          maximumStrokeWidth: 5,<br>        ),<br>      ),<br>      actions: [<br>        TextButton(<br>          onPressed: () {<br>            _signaturePadKey.currentState?.clear();<br>          },<br>          child: const Text(&quot;Clear&quot;),<br>        ),<br>        ElevatedButton(<br>            onPressed: () async {<br>              mySignature = await _signaturePadKey.currentState?.toImage();<br>              if (_signaturePadKey.currentState?.toImage() != null) {<br>                Navigator.of(context).pop();<br>              }<br>            },<br>            child: const Text(&quot;Save&quot;)),<br>      ],<br>    );<br>  }<br>}</pre><p>SfSignaturePad() is a Syncfusion widget. You need GlobalKey to get its current state object.</p><pre>...<br>SfSignaturePad(<br>          key: _signaturePadKey,<br>          strokeColor: Colors.black,<br>          backgroundColor: Colors.white,<br>          minimumStrokeWidth: 4,<br>          maximumStrokeWidth: 5,<br>        ),<br>...<br>mySignature = await _signaturePadKey.currentState?.toImage();<br>              if (_signaturePadKey.currentState?.toImage() != null) {<br>                Navigator.of(context).pop();<br>              }<br>...</pre><p>Save as image =&gt; _signaturePadKey.currentState?.toImage()</p><blockquote>For more details you may read <a href="https://pub.dev/packages/syncfusion_flutter_signaturepad">Syncfusion documentation</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Gm49TAqOxHoodFgIgzpgpA.png" /><figcaption>Signature Pad Dialog</figcaption></figure><p>Next, create a widget if the signature is empty and display it. Create a file SignaturePlacholder widget.</p><pre>class SignaturePlaceholder extends StatelessWidget {<br>  const SignaturePlaceholder({Key? key}) : super(key: key);<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Column(<br>      children: const [<br>        ClipRRect(<br>          borderRadius: BorderRadius.all(Radius.circular(10.0)),<br>          child: Icon(Icons.gesture),<br>        ),<br>        Text(&quot;Add Signature&quot;),<br>      ],<br>    );<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*piPMmnGoIEHRm9Oxs6fv1A.png" /><figcaption>Placeholder</figcaption></figure><p><strong>Add State</strong></p><p>Create a state for signature</p><pre>final signatureProvider = StateProvider&lt;ui.Image?&gt;((ref) =&gt; null);</pre><p>the signatureProvider will hold the current state of the signature image.</p><p>Next, Make a variable for signatureProvider, Add this code:</p><pre>final mySign = ref.watch(signatureProvider);</pre><p>The signature Page become like this.</p><pre>class SignaturePage extends ConsumerWidget {<br>  const SignaturePage({Key? key}) : super(key: key);<br><br>  @override<br>  Widget build(BuildContext context, WidgetRef ref) {<br>    //mySign as ui.Image<br>    final mySign = ref.watch(signatureProvide);<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: const Text(&quot;Signature&quot;),<br>      ),</pre><p>Next, Go to SignaturePadDialog file. Add this below code at onPress save to notify and update the stateProvider.</p><pre>ref.read(signatureProvider.notifier)<br>   .update((state) =&gt; mySignature);</pre><p>then signature pad dialog be like this</p><pre> ElevatedButton(<br>          onPressed: () async {<br>              mySignature = await _signaturePadKey.currentState?.toImage();<br>              if (_signaturePadKey.currentState?.toImage() != null) {<br>                ref<br>                    .read(signatureProvider.notifier)<br>                    .update((state) =&gt; mySignature);<br>                Navigator.of(context).pop();<br>              }<br>            },<br>            child: const Text(&quot;Save&quot;)),<br>      ],</pre><p>Run the app</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FtDqH5BouF4JOQwLWsv%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExNTkxNzVhNTc0NTFiNzc0NGNiMTE5Y2RmZWVkZDY0YTFjODhiN2RkNyZjdD1n%2FtDqH5BouF4JOQwLWsv%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FtDqH5BouF4JOQwLWsv%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="536" frameborder="0" scrolling="no"><a href="https://medium.com/media/845198c3db8e139dbc4ebaf23a6f69c5/href">https://medium.com/media/845198c3db8e139dbc4ebaf23a6f69c5/href</a></iframe><p>That’s it.</p><blockquote>You can use CustomPainter to display the signature instead of using the RawImage widget.</blockquote><p>Create signature_image.dart widget and add this code below.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;dart:ui&#39; as ui;<br><br>class SignatureImage extends StatelessWidget {<br>  final ui.Image image;<br><br>  const SignatureImage({<br>    Key? key,<br>    required this.image,<br>  }) : super(key: key);<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return CustomPaint(painter: UIImagePainter(image));<br>  }<br>}<br><br>class UIImagePainter extends CustomPainter {<br>  final ui.Image image;<br><br>  UIImagePainter(this.image);<br><br>  @override<br>  void paint(Canvas canvas, Size size) {<br>    canvas.drawImageRect(<br>      image,<br>      Rect.fromLTWH(0, 0, image.width.toDouble(), image.height.toDouble()),<br>      Rect.fromLTWH(0, 0, size.width, size.height),<br>      Paint(),<br>    );<br>  }<br><br>  @override<br>  bool shouldRepaint(UIImagePainter oldDelegate) {<br>    return image != oldDelegate.image;<br>  }<br>}</pre><p>Above code will render the signature image. Then replace RawImage on the signature page, and wrap it with Container and ClipRRect widgets.</p><pre>...<br> mySign != null<br>         ? Container(<br>          decoration: BoxDecoration(<br>              border: Border.all(<br>                  width: 1,<br>                  color: Theme.of(context).primaryColor)),<br>          height: 250,<br>          width: double.infinity,<br>          child: ClipRRect(<br>            borderRadius: BorderRadius.circular(10),<br>            child: SignatureImage(image: mySign),<br>          ),<br>        )<br>      : const SignaturePlaceholder(),<br>...</pre><p>Here is the result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*vZAczD4h6dsWJZgpRFZn-g.png" /></figure><p>What’s next..???</p><blockquote>You may save the image into database, you can save it as String by encode to base64 and decode to make it as image again.</blockquote><p>You can save the signature into storage or a database, but the best way is to use a database and put it into a string by converting it to Base64. The signature is in png converting it to Uint8List() and then to base64.</p><p>For example:</p><pre>...<br> final pngByteData =<br>        await mySignatureImage.toByteData(format: ui.ImageByteFormat.png);<br>    final pngBytes = pngByteData?.buffer.asUint8List();<br>    if (pngBytes != null) {<br>      String signatureToBase64 = base64Encode(pngBytes);<br>      //The rest of your code<br>    }<br>...</pre><p>Here is the print of signatureToBase64 if you wondering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N9FQY0C2PH6AvKojb621Vw.png" /></figure><p>its looooooooooooooonggggggg striiiiiiinggg.</p><p>Bye, See ya later.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a47642708830" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Local Notifications]]></title>
            <link>https://medium.com/@ogak/flutter-local-notifications-a2ee98d63c53?source=rss-37cb323d24b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2ee98d63c53</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Ogak Dev]]></dc:creator>
            <pubDate>Tue, 28 Feb 2023 00:07:56 GMT</pubDate>
            <atom:updated>2023-02-28T00:07:56.717Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*E8CXnMbbIEcASke4B1rDcA.png" /></figure><p>Notifications are one of the essential things in the app. Notifications are used to send users information/messages or to notify users of something important happening in the application so that the application is more interactive.<br><strong>There are 2 types of notifications :</strong></p><ol><li><strong>Local Notification (LN)</strong>, allows messaging locally.</li><li><strong>Push Notification (PN)</strong>, allows messages to go through the backend server.</li></ol><p>In Flutter many notification plugins can be used depending on the app&#39;s needs, such as <a href="https://pub.dev/packages/firebase_messaging">firebase_messaging</a>, <a href="https://pub.dev/packages/onesignal_flutter">onesignal_flutter</a>, and <a href="https://pub.dev/packages/flutter_local_notifications">flutter_local_notifications</a>.</p><p>In this article, we will implement <strong>local push notifications.</strong></p><p><strong>Let’s get started. Set up flutter projects and environment.</strong></p><p>I will use the default Flutter app counter as an example.</p><ol><li>Local Notification</li></ol><p>Add flutter_local_notifications package in pubspec.yaml</p><pre>flutter pub add flutter_local_notifications</pre><p>Create a service for notification</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_local_notifications/flutter_local_notifications.dart&#39;;<br><br>class NotificationService {<br>  final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =<br>      FlutterLocalNotificationsPlugin();<br><br>  Future&lt;void&gt; init() async {<br>    const AndroidInitializationSettings androidInitializationSettings =<br>        AndroidInitializationSettings(&#39;@mipmap/ic_launcher&#39;);<br>    const InitializationSettings initializationSettings =<br>        InitializationSettings(<br>      android: androidInitializationSettings,<br>    );<br>    await flutterLocalNotificationsPlugin<br>        .initialize(initializationSettings)<br>        .then((_) {<br>      debugPrint(&quot;InitPlugin: Success!&quot;);<br>    }).catchError((Object error) {<br>      debugPrint(&#39;Error: $error&#39;);<br>    });<br>  }<br><br>  sendNotification(String title, String body) async {<br>    const androidNotificationDetail = AndroidNotificationDetails(<br>        &quot;my-channel-id&quot;, &quot;my-channel-name&quot;,<br>        importance: Importance.high, ticker: &#39;ticker&#39;);<br>    const notificationDetail = NotificationDetails(<br>      android: androidNotificationDetail,<br>    );<br>    const id = 99;<br>    await flutterLocalNotificationsPlugin.show(<br>        id, title, body, notificationDetail);<br>  }<br>}</pre><p>Method init() will initialize the notification plugin, and sendNotification() will be a function with parameters title and the body of notifications.</p><p>From Android Oreo, there is a feature called “Channel” to group the notifications which can be turned off/on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*nE7BRqCuV-MJoGCyyQczuQ.png" /><figcaption>Channel</figcaption></figure><blockquote>Channels are a feature on Android to differentiate notifications on apps. This feature is not available on iOS. Each channel can have its own preferences.</blockquote><p>Add notification service into main.dart</p><pre>Future&lt;void&gt; main() async {<br>  WidgetsFlutterBinding.ensureInitialized();<br>  await NotificationService().init();<br>  runApp(const MyApp());<br>}</pre><p>After initializing success, you can call the sendNotification() function to send the local notif based on your needs.</p><pre>  ...<br>  int _counter = 0;<br><br>  void displayNotif() {<br>    String message = &quot;You have push $_counter time(s)&quot;;<br>    NotificationService().sendNotification(widget.title, message);<br>  }<br><br>  void _incrementCounter() {<br>    setState(() {<br>      _counter++;<br>    });<br>  }<br>  <br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>    ...<br>            SizedBox(<br>              width: 240,<br>              child: ElevatedButton(<br>                onPressed: () {<br>                  displayNotif();<br>                },<br>                child: const Text(&quot;Local Push Notification&quot;),<br>              ),<br>            )<br>    ...  </pre><p>I create a displayNotif() function and called it when pressing the button to trigger the push notification.</p><p>Run the app and trigger the push notifications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*8reYEwyLuvrLXEhs9EkMrg.png" /><figcaption>Local PN</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2ee98d63c53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter]]></title>
            <link>https://medium.com/@ogak/flutter-a6dc1d5b550e?source=rss-37cb323d24b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6dc1d5b550e</guid>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Ogak Dev]]></dc:creator>
            <pubDate>Sun, 24 Jul 2022 03:14:07 GMT</pubDate>
            <atom:updated>2022-07-24T03:17:29.397Z</atom:updated>
            <content:encoded><![CDATA[<p>Flutter adalah toolkit untuk membuat UI aplikasi dalam satu codebase yang kemudian apps di susun (compile) secara native ke dalam mobile, web, dan desktop.</p><p>Flutter dibuat dengan bahasa pemrograman C, C++, Dart, dan Skia (2D rendering engine) dibuat oleh tim Google, tim komunitas flutter, maupun individu sehingga bersifat open-source, rilis alpha pada bulan mei tahun 2017 kemudian rilis stabil tahun 2018.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*uQJEU0UcyVRpPAo4UYCjzw.png" /><figcaption>Flutter System Architecture, Source: <a href="https://docs.google.com/presentation/d/1cw7A4HbvM_Abv320rVgPVGiUP2msVs7tfGbkgdrTy0I/edit#slide=id.gbb3c3233b_0_162">https://docs.google.com/presentation/d/1cw7A4HbvM_Abv320rVgPVGiUP2msVs7tfGbkgdrTy0I/edit#slide=id.gbb3c3233b_0_162</a></figcaption></figure><p><strong>Dart</strong></p><p>Kode flutter ditulis dengan bahasa pemrograman Dart, “Mengapa Dart ?” menurut tim pengembang Flutter, mereka menemukan banyak bahasa pemrograman yang cocok dengan kriteria untuk Flutter, mereka memutuskan memilih Dart karena sangat cocok untuk kriteria Flutter, berdasarkan <em>developer productivity, object-orientation, predictable, high performance, dan fast allocation. </em>Bahasa pemrograman dart sendiri syntax-nya mirip dengan gabungan keluarga bahasa C dan Java.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*-GL0OGCOVTqp9gYPgsHQfQ.png" /><figcaption>Sample code dart. Source dartpad.dev</figcaption></figure><p><strong>Widgets</strong></p><p>Flutter terdiri dari berbagai macam widgets, <strong>Widget</strong> adalah komponen-komponen pendukung pada <strong>Flutter</strong> seperti Button, Text, Icon dan lain sebagainya. Semua tampilan tersusun oleh <strong>Widget</strong>. Tipe widget terdiri dari <strong>Stateless</strong>, <strong>Stateful</strong>, dan <strong>Inheritance</strong>, widget dapat di customize sehingga dapat di-reusable ataupun membentuk tampilan user interface yang diinginkan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q4oPQoECSW_UoQaIuN1XqA.png" /><figcaption>Kumpulan Widget. Source: <a href="https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DWOvj84xq_fc&amp;psig=AOvVaw34Jx--Ci0v3vAIqZsZwcis&amp;ust=1648297023978000&amp;source=images&amp;cd=vfe&amp;ved=0CAwQjhxqFwoTCNCK94if4fYCFQAAAAAdAAAAABAJ">Youtube</a></figcaption></figure><p>Berikut beberapa widget yang biasa digunakan:</p><ul><li><strong>StatelessWidget:</strong>– A widget that cannot be re-drawn by changes to its properties is called StatelessWedget.</li><li><strong>StatefulWidget:-</strong> The stateful Widget can be redrawn when its setState function is called.</li><li><strong>Center:- </strong>A widget used to center its child inside the parent widget.</li><li><strong>Column:- </strong>The column widget lays out its child widgets also add in vertically.</li><li><strong>Row:- </strong>Row widget accepts a list of layouts and lays them out horizontally.</li><li><strong>ListView:-</strong> The list view is a very helpful widget to show a large number of data usually of type ListTile, linearly</li><li><strong>GridView:-</strong> Divides the horizontal and vertical space into your grids layout.</li><li><strong>Plugins:-</strong> The plugin is a program that extends the capabilities of a flutter on various platforms.</li><li><strong>Packages:-</strong> Use flutter as their base to add new functionality to flutter itself.</li><li><strong>Container:-</strong> A stateless widget usually used to contain another layout with decorations.</li><li><strong>Image:-</strong> A Image widget used to display images either locally or from the network.</li><li><strong>Text:-</strong> Display texts can be styled using its property of TextStyle that can show a label.</li><li><strong>Scaffold:-</strong> A stateful widget that is used for the start point of your App.</li><li><strong>AppBar:-</strong> AppBar is embedded usually inside your scaffold to display a bar on the top of your App.</li><li><strong>Stack:-</strong> You use this layout in order to display widgets that consume the same space.</li><li><strong>GestureDetector:-</strong> A stateless widget that can detect various gestures.</li><li><strong>Icons:-</strong> A stateless layout that is usually used to display an object with an object type IconDate.</li><li><strong>PageView:-</strong> PageView is used to scroll and paginate your widgets, great for image galleries.</li><li><strong>LayoutBuilder:</strong>– A widget that gives you information about the parent layout.</li><li><strong>FutureBuilder:-</strong> It is a Layout that child widget based on the status of a future.</li><li><strong>StreamBuilder:-</strong> Listens to a stream and builds a widget-based o change to the stream’s status.</li></ul><p>Sumber: <a href="https://www.codeplayon.com/2021/11/learn-flutter-layout-cheat-sheet/">Codeplayon</a></p><p><strong>Library (pub)</strong></p><p>Flutter juga memiliki banyak libraries yang mendukung dalam membuat aplikasi android atau iOS, yaitu <a href="https://pub.dev/"><em>Pub</em></a>, pub merupakan package manager atau package repository untuk Dart dan Flutter, sama halnya NPM (Node package module) dalam NodeJS, library yang terdapat dalam pub merupakan buatan individu, perusahaan atau komunitas yang bersifat open-source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*708TDxHFHm1wTkamVG7Chw.png" /><figcaption>Kumpulan library flutter dan dart</figcaption></figure><p>Dari package repository pub, developer dapat mencari library yang diinginkan atau sesuai dengan kebutuhan project.</p><p>Untuk menambah library ke dalam project cukup mudah, tambahkan nama library serta versi yang ingin digunakan ke dalam file <strong>pubspec.yaml</strong> seperti contoh berikut:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*GlVUvayaVB0EZUR28U3X9Q.png" /><figcaption>Contoh file pubspec.yaml</figcaption></figure><p><a href="http://yaml.org/">YAML</a> adalah serialisasi data untuk semua bahasa pemrograman yang mudah dibaca.</p><p>Pubspec juga dapat dikendalikan melalui command-line, misal menambahkan dependency logging</p><p><em>flutter pub add logging</em></p><p>perintah tersebut akan mendownload package <em>logging.</em></p><blockquote><em>Logging adalah salah satu package flutter untuk debugging dan error log</em></blockquote><p>Berikut adalah cheat sheet pub command-line:</p><ul><li><strong>add</strong> Add a dependency to pubspec.yaml</li><li><strong>cache</strong> Work with the Pub system cache.</li><li><strong>deps</strong> Print package dependencies.</li><li><strong>downgrade</strong> Downgrade packages in a Flutter project.</li><li><strong>get</strong> Get packages in a Flutter project.</li><li><strong>global</strong> Work with Pub global packages.</li><li><strong>login</strong> Log into pub.dev..</li><li><strong>logout</strong> Log out of pub.dev..</li><li><strong>outdated</strong> Analyze dependencies to find which ones can be upgraded.</li><li><strong>pub</strong> Pass the remaining arguments to Dart’s “pub” tool.</li><li><strong>publish</strong> Publish the current package to pub.dartlang.org.</li><li><strong>remove</strong> Removes a dependency from the current package..</li><li><strong>run</strong> Run an executable from a package.</li><li><strong>test</strong> Run the “test” package.</li><li><strong>upgrade</strong> Upgrade the current package’s dependencies to latest versions.</li><li><strong>uploader</strong> Manage uploaders for a package on pub.dev.</li><li><strong>version</strong> Print Pub version.</li></ul><p>Source: <a href="https://suragch.medium.com/all-about-the-pub-command-line-tool-for-flutter-and-dart-52339d594d96">suragch.medium</a></p><p><strong>Build &amp; Compile</strong></p><p>Dalam build &amp; compile ke berbagai platform, Flutter SDK membutuhkan requirements tambahan untuk setiap platform, misal:</p><ol><li><strong>Windows</strong> =&gt; Visual Studio dengan C++ development tools.</li><li><strong>iOS dan MacOS</strong> =&gt; X-Code dan Cocoapods (untuk plugin)</li><li><strong>Linux</strong> =&gt; <a href="https://clang.llvm.org/">Clang</a>, <a href="https://cmake.org/">CMake</a>, <a href="https://developer.gnome.org/gtk3/3.2/gtk-getting-started.html">GTK development headers</a>, <a href="https://ninja-build.org/">Ninja build</a>, <a href="https://www.freedesktop.org/wiki/Software/pkg-config/">pkg-config</a>, <a href="https://packages.debian.org/sid/liblzma-dev">liblzma-dev</a></li><li><strong>Web </strong>=&gt; Untuk web cukup dengan Flutter SDK serta Chrome browser untuk debugging.</li><li><strong>Android</strong> =&gt; Android Studio serta Android SDK</li></ol><p>Untuk melihat requirements sudah memenuhi atau tidak cukup jalankan perintah &gt; <em>flutter doctor</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*yY3wPxrfAmrgc9FnGhev_w.png" /><figcaption>Contoh requirements Android development menggunakan OS Linux Ubuntu</figcaption></figure><p><strong>App Size</strong></p><p>Saya mencoba membuat apps sederhana yang akan di build ke dalam Android apps dan melihat ukuran file apk-nya.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*IL1tNR9fk3o3p84TlN0DBA.gif" /></figure><p>Ukuran atau size apps dalam bentuk apk-debug adalah <strong>58 Mb</strong> dan ketika sudah terinstall adalah sekitar <strong>90.47 Mb.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*o2PzLTRKu4-ZaSEwOWyVOw.png" /><figcaption>app size debug emulator</figcaption></figure><p>Untuk yang apk-release adalah <strong>18.2 Mb, </strong>setelah terinstall menjadi <strong>32.63 Mb.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*bfguGSwsUcHNppe8gcfB2g.jpeg" /><figcaption>App size real android device</figcaption></figure><p>App size besar (fat APK) ini dikarenakan dalam satu APK memiliki beberapa ABI (Application Binary Interface), sehingga APK support multiple arsitektur (<a href="https://developer.android.com/ndk/guides/abis#v7a">armeabi-v7a</a> (ARM 32-bit), <a href="https://developer.android.com/ndk/guides/abis#arm64-v8a">arm64-v8a</a> (ARM 64-bit), and <a href="https://developer.android.com/ndk/guides/abis#86-64">x86–64</a> (x86 64-bit) dan juga kompatibilitas.</p><p>Untuk membuat APK build lebih ramping cukup build sesuai arsitektur yang digunakan. Dalam flutter &gt; <em>flutter build apk — split-per-abi </em>perintah tersebut akan menghasilkan build per arsitektur.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*n7Fpkhy0AHADZ-NA1ANcRw.jpeg" /><figcaption>Size APK per arsitektur</figcaption></figure><p>Ukuran app size ini mungkin juga berpengaruh dari plugin (pub) yang digunakan.</p><p>Sekian dulu pembahasan mengenai flutter secara umum, untuk yang lain-nya mungkin dibahas terpisah.</p><p>Saat artikel ini dibuat Flutter 3.0 sudah release, ini menandakan bahwa Flutter merupakan framework yang sangat berkembang pesat. Di Flutter 3.0 ini desktop platform (Windows, Linux, dan macOS) sudah mencapai tingkat stabil dan sebagai platform UI toolkit terdapat beberapa update dalam mobile development yaitu telah support untuk pengembangan foldable phone (Hp Lipat), Material 3, update untuk iOS, versi Gradle ditingkatkan, peningkatan pada web development, dan Ads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K1Ru7PVkH74N56hgjBTjjQ.png" /></figure><p>Thanks for today. Have a Good day!</p><blockquote><strong>Knowledge is a garden, If it isn’t cultivated, it can’t be harvested.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6dc1d5b550e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mengaktifkan nginx_stub status]]></title>
            <link>https://medium.com/@ogak/mengaktifkan-nginx-stub-status-c4ff0df2df0b?source=rss-37cb323d24b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4ff0df2df0b</guid>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Ogak Dev]]></dc:creator>
            <pubDate>Wed, 20 Jul 2022 13:33:04 GMT</pubDate>
            <atom:updated>2022-07-20T13:33:04.239Z</atom:updated>
            <content:encoded><![CDATA[<p>Pada waktu yang lalu saya mencoba monitoring nginx status menggunakan New Relic monitoring. Setelah berhasil instalasi agent kemudian integrasi ke nginx selalu error, setelah membaca dokumentasi new relic, problemnya ialah nginx_stub belum diaktifkan.</p><p>Module nginx_stub ini berfungsi untuk menyediakan informasi dasar status nginx. Informasi dasar tersebut adalah</p><ol><li>Active connections<br>Jumlah client yang aktif termasuk Waiting connection.</li><li>Accepts<br>Jumlah total koneksi client yang diterima atau masuk.</li><li>Handled<br>Jumlah total koneksi yang di proses.</li><li>Requests<br>Jumlah total rekues client.</li><li>Reading<br>Jumlah koneksi dimana nginx membaca request header saat ini.</li><li>Writing<br>Jumlah koneksi dimana nginx merespon balik client.</li><li>Waiting<br>Jumlah koneksi yang sedang idle saat ini.</li></ol><p>Untuk mengaktifkan nginx_stub status ini saya membuat file <strong>status.conf </strong>di dalam folder <strong>/etc/nginx/conf.d/ </strong>kemudian restart nginx.</p><p><strong>Step by step</strong></p><p>Di dalam folder /etc/nginx/conf.d/ buat file status.conf</p><pre>cd /etc/nginx/conf.d/<br>nano status.conf</pre><p>Di dalam file <strong>status.conf </strong>tambahkan script berikut:</p><pre>server {<br>    listen localhost;<br>    server_name status.localhost;<br>    keepalive_timeout 0;<br><br>    access_log off;<br><br>    allow 127.0.0.1;<br>    deny all;<br><br>    location /nginx_status {<br>        stub_status on;<br>    }<br>}</pre><p>Restart/reload nginx.</p><pre>sudo nginx -s reload</pre><p>Test menggunakan curl</p><pre>curl <a href="http://127.0.0.1/nginx_status">http://127.0.0.1/nginx_status</a></pre><pre>Active connections: 4 <br>server accepts handled requests<br> 1768047 1768047 2273296 <br>Reading: 0 Writing: 1 Waiting: 3</pre><p>Jika muncul status informasi maka stub_status telah berjalan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*GMnfudVcYbMP2KaGdPGI0g.png" /></figure><p>That’s it. Have a good day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4ff0df2df0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>