<?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 Ecco Suprastyo on Medium]]></title>
        <description><![CDATA[Stories by Ecco Suprastyo on Medium]]></description>
        <link>https://medium.com/@ekosuprastyo15?source=rss-ddb5d4023977------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*A5Us5CSuXlRnY5Hn7x2_rg.jpeg</url>
            <title>Stories by Ecco Suprastyo on Medium</title>
            <link>https://medium.com/@ekosuprastyo15?source=rss-ddb5d4023977------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 23:38:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ekosuprastyo15/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[Vuex Login Form Example]]></title>
            <link>https://medium.com/@ekosuprastyo15/vuex-login-form-example-26b514c9dabc?source=rss-ddb5d4023977------2</link>
            <guid isPermaLink="false">https://medium.com/p/26b514c9dabc</guid>
            <category><![CDATA[vuex-login-store]]></category>
            <category><![CDATA[vuejs-login]]></category>
            <category><![CDATA[vuex-login]]></category>
            <category><![CDATA[vuejs-form-login]]></category>
            <category><![CDATA[vuex-form-login]]></category>
            <dc:creator><![CDATA[Ecco Suprastyo]]></dc:creator>
            <pubDate>Fri, 05 Jun 2020 10:00:02 GMT</pubDate>
            <atom:updated>2024-01-04T02:45:12.021Z</atom:updated>
            <content:encoded><![CDATA[<p>This tutorial will discuss about Vuex Login Form Example. Before we start to discuss about <strong>vuex store login example</strong>, What is Vuex? Vuex is a <strong>state management pattern + library</strong> for Vue.js applications. It serves as a centralized store for all the components in an application, with rules ensuring that the state can only be mutated in a predictable fashion. It also integrates with Vue’s official <a href="https://github.com/vuejs/vue-devtools">devtools extension</a> to provide advanced features such as zero-config time-travel debugging and state snapshot export / import.</p><p>You can read about Vuex in here <a href="https://vuex.vuejs.org/">https://vuex.vuejs.org/.</a></p><h3>Intoduction</h3><p>So simply vuex is a state management pattern on vuejs which has a centralized store for all components in the vuejs application that we are going to make.</p><p>in making this tutorial we will make 3 parts:</p><ol><li>Create <strong>state</strong>, the source of truth that drives our app;</li><li>Create <strong>view</strong>, a declarative mapping of the <strong>state</strong>;</li><li>Create <strong>actions</strong>, the possible ways the state could change in reaction to user inputs from the <strong>view</strong>.</li></ol><h3>Preparation</h3><p>To get started let’s make a vue project first, Please type the following command in your cmd / terminal:</p><pre>vue create vuex-login-example</pre><p>This command will create a new project called <em>vuex-login-example</em> for us. Open the project directory and then install vuex.</p><pre>npm install vuex --save</pre><h3>Start Coding</h3><h3>1. Store</h3><p>First create a new folder called <strong><em>store</em></strong> in the <strong><em>src/</em></strong> folder then also create a new file called <strong><em>index.js</em></strong> in the store folder then in the <strong><em>index.js</em></strong> file type the following script:</p><pre>import Vue from &#39;vue&#39;;<br>import Vuex from &#39;vuex&#39;;<br>//general<br>import { login } from &#39;./login.module&#39;;</pre><pre>Vue.use(Vuex);</pre><pre>export const store = new Vuex.Store({<br>    modules: {<br>        login<br>    }<br>});</pre><p>After that create a store to login :</p><pre>import { loginService } from &#39;../services/login.service&#39;;<br>import { router } from &#39;../router&#39;;</pre><pre>const state = {<br>    isLogin: false,<br>    token:null,<br>    user:null,<br>};</pre><pre>const actions = {<br>    login({commit}, { username, password }) {<br>        commit(&#39;loginRequest&#39;, { username });<br>    <br>        let result = loginService.login(username, password);<br>        if(result){<br>            commit(&#39;loginSuccess&#39;);<br>            console.log(&quot;login success&quot;);<br>            router.push(&#39;/home&#39;);<br>        }<br>    },<br>    logout({commit}) {<br>        commit(&#39;resetState&#39;);<br>        router.push(&#39;/&#39;);<br>    },<br>    clearState ({ commit }) {<br>        commit(&#39;resetState&#39;);<br>    },<br>};</pre><pre>const mutations = {<br>    resetState (state) {<br>        state.isLogin=false;<br>        state.token=null;<br>        state.user=null;<br>    },<br>    loginRequest(state, user) {<br>        state.isLogin=true;<br>        state.token=null;<br>        state.user=user;<br>    },<br>    loginSuccess(state) {<br>        state.isLogin=true;<br>        state.token=null;<br>        state.user=null;<br>    },<br>    loginFailure(state) {<br>        state.isLogin=false;<br>    },<br>};</pre><pre>export const login = {<br>    namespaced: true,<br>    state,<br>    actions,<br>    mutations<br>};</pre><h3>2. Service</h3><p>In this section it is used for communication to the backend. usually the vue uses the axios library for communication to the backend. First create a new folder called <strong><em>services</em></strong> in the <strong><em>src/</em></strong> folder then also create a new file called <strong><em>login.service.js</em></strong> in the services folder then in the <strong><em>login.service.js</em></strong> file type the following script:</p><pre>export const loginService = {<br>    login<br>};</pre><pre>function login(username, password) {<br>    if(username != &quot;&quot; &amp;&amp; password != &quot;&quot;) {<br>        return true;<br>    }<br>}</pre><h3>3. Router</h3><p>First create a new folder called <strong><em>router </em></strong>in the <strong><em>src/</em></strong> folder then also create a new file called <strong><em>index.js</em></strong> in the router folder then in the <strong><em>index.js</em></strong> file type the following script:</p><pre>import Vue from &#39;vue&#39;<br>import Router from &#39;vue-router&#39;</pre><pre>Vue.use(Router);</pre><pre>export const router = new Router({<br>    scrollBehavior() {<br>        return window.scrollTo({ top: 0, behavior: &#39;smooth&#39; });<br>    },<br>    routes: [<br>        <br>        {<br>            path: &#39;/home&#39;,<br>            name: &#39;home&#39;,<br>            component: () =&gt; import(&#39;../components/HomeWorld.vue&#39;),<br>        },</pre><pre>        {<br>            path: &#39;/&#39;,<br>            name: &#39;login&#39;,<br>            component: () =&gt; import(&#39;../components/LoginWorld.vue&#39;),<br>        }</pre><pre>    ]<br>})</pre><h3>4. Components</h3><p>The folder components already in the <strong><em>src/</em></strong> folder then create a new file called <strong><em>LoginWorld.vue</em></strong> in the components folder then in the <strong><em>LoginWorld.vue</em></strong> file type the following script:</p><pre>&lt;template&gt;<br>    &lt;div id=&quot;login&quot;&gt;<br>        &lt;div class=&quot;h-100 bg-plum-plate-login bg-animation&quot;&gt;<br>            &lt;div class=&quot;d-flex h-100 justify-content-center align-items-center&quot;&gt;<br>                &lt;b-col md=&quot;8&quot; class=&quot;mx-auto app-login-box&quot;&gt;<br>                    &lt;div class=&quot;modal-dialog w-100 mx-auto&quot;&gt;<br>                        &lt;div class=&quot;modal-content&quot;&gt;<br>                            &lt;div class=&quot;modal-body&quot;&gt;<br>                                &lt;div class=&quot;h5 modal-title text-center&quot;&gt;<br>                                    &lt;h4 class=&quot;mt-2&quot;&gt;<br>                                        &lt;div&gt;Welcome,&lt;/div&gt;<br>                                        &lt;span&gt;Please sign in to your account below.&lt;/span&gt;<br>                                    &lt;/h4&gt;<br>                                &lt;/div&gt;<br>                                &lt;form ref=&quot;form&quot;&gt;<br>                                    &lt;b-form-group id=&quot;usernameGroup1&quot;<br>                                                label-for=&quot;usernameLabel1&quot;&gt;<br>                                        &lt;b-form-input id=&quot;usernameInput&quot;<br>                                                    type=&quot;text&quot;<br>                                                    name=&quot;username&quot; <br>                                                    v-model=&quot;username&quot;<br>                                                    required<br>                                                    placeholder=&quot;Enter username...&quot;&gt;<br>                                        &lt;/b-form-input&gt;<br>                                        <br>                                    &lt;/b-form-group&gt;<br>                                    &lt;b-form-group id=&quot;exampleInputGroup2&quot;<br>                                                label-for=&quot;exampleInput2&quot;&gt;<br>                                        &lt;b-form-input id=&quot;exampleInput2&quot;<br>                                                    type=&quot;password&quot;<br>                                                    name=&quot;password&quot; <br>                                                    v-model=&quot;password&quot;<br>                                                    required<br>                                                    placeholder=&quot;Enter password...&quot;&gt;<br>                                        &lt;/b-form-input&gt;<br>                                    &lt;/b-form-group&gt;<br>                                   <br>                                &lt;/form&gt;<br>                                &lt;div class=&quot;divider&quot;/&gt;<br>                            &lt;/div&gt;<br>                            &lt;div class=&quot;modal-footer clearfix&quot;&gt;<br>                                &lt;div class=&quot;float-right&quot;&gt;<br>                                    &lt;b-button variant=&quot;primary&quot;  @click=&quot;doLogin&quot; size=&quot;lg&quot;&gt;Login&lt;/b-button&gt;<br>                                &lt;/div&gt;<br>                            &lt;/div&gt;<br>                        &lt;/div&gt;<br>                    &lt;/div&gt;<br>                    &lt;div class=&quot;text-center text-white opacity-8 mt-3&quot;&gt;<br>                        &lt;strong&gt; Copyright &amp;copy; camellabs.com &lt;/strong&gt;<br>                    &lt;/div&gt;<br>                &lt;/b-col&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/template&gt;<br></pre><pre>&lt;script&gt;<br>    import {  mapActions } from &#39;vuex&#39;<br>    export default {<br>        name: &#39;Login&#39;,<br>        data: () =&gt; ({<br>            username: &quot;&quot;,<br>            password: &quot;&quot;,<br>        }),<br>        methods: {<br>            ...mapActions(&#39;login&#39;, {<br>                login: &#39;login&#39;<br>            }),<br>                reset() {<br>                this.$refs.form.reset();<br>            },<br>            doLogin() {<br>                const { username, password } = this;<br>                if(this.username != &quot;&quot; &amp;&amp; this.password != &quot;&quot;) {<br>                    this.login({ username, password });<br>                }else{<br>                    alert(&#39;Please fill the text!&#39;);<br>                }<br>            }<br>        },<br>    }<br>&lt;/script&gt;</pre><p>Later, create a new file called <strong><em>HomeWorld.vue</em></strong> in the components folder. And then in the <strong><em>HomeWorld.vue</em></strong> file type the following script:</p><pre>&lt;template&gt;<br>    &lt;div id=&quot;home&quot;&gt;<br>         {{ info }}<br>         &lt;b-button variant=&quot;primary&quot;  @click=&quot;doLogout&quot; size=&quot;lg&quot;&gt;Logout&lt;/b-button&gt;<br>  &lt;/div&gt;<br>    <br>&lt;/template&gt;</pre><pre>&lt;script&gt;<br>import {  mapActions } from &#39;vuex&#39;<br>export default {<br>   name: &#39;home&#39;,   <br>   data () {<br>    return {<br>      info: &#39;You are have been login and this is Home Page&#39;<br>    }<br>  },<br>  methods: {<br>            ...mapActions(&#39;login&#39;, {<br>                logout: &#39;logout&#39;<br>            }),<br>                reset() {<br>                this.$refs.form.reset();<br>            },<br>            doLogout() {<br>                this.logout();<br>            }<br>        },<br>}<br>&lt;/script&gt;</pre><p>After completing the coding for all parts, at the end we will complete our project by changing the files that have existed since this project was created.</p><p>now, edit <strong><em>App.vue</em></strong> like below :</p><pre>&lt;template&gt;<br>  &lt;div id=&quot;app&quot;&gt;<br>    &lt;img alt=&quot;Vue logo&quot; src=&quot;./assets/logo.png&quot;&gt;<br>    &lt;router-view&gt;&lt;/router-view&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><pre>&lt;script&gt;<br>export default {<br>  name: &#39;App&#39;<br>}<br>&lt;/script&gt;</pre><pre>&lt;style&gt;<br>#app {<br>  font-family: Avenir, Helvetica, Arial, sans-serif;<br>  -webkit-font-smoothing: antialiased;<br>  -moz-osx-font-smoothing: grayscale;<br>  text-align: center;<br>  color: #2c3e50;<br>  margin-top: 60px;<br>}<br>&lt;/style&gt;</pre><p>When finished, open the <strong><em>main.js</em></strong> file which is in the src folder and then change the script so that it looks like this:</p><pre>import Vue from &#39;vue&#39;<br>import BootstrapVue from &quot;bootstrap-vue&quot;<br>import App from &#39;./App.vue&#39;<br>import { store } from &#39;./store&#39;;<br>import { router } from &#39;./router&#39;;</pre><pre>Vue.config.productionTip = false<br>Vue.use(BootstrapVue);<br></pre><pre>new Vue({<br>  el: &#39;#app&#39;,<br>  router,<br>  store,<br>  render: h =&gt; h(App)<br>})</pre><p>After everything is finished, let’s run the project by first typing the following command in cmd / terminal:</p><pre>npm run serve</pre><p>If it works and there are no errors then the appearance will be more or less the same as below:</p><p>For complete source code you can see vuex login store in <a href="https://github.com/eccosuprastyo/vue/tree/master/vuex-login-example">Here</a>.</p><p>Thank you for reading this article about <strong>Vuex Login Form Example</strong>, I hope this article is useful for you. Visit My Github about Flutter in <a href="https://github.com/eccosuprastyo/vue">Here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jvOqJanNVUAf9Af_qyL5vw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26b514c9dabc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a WCF Rest Service C#]]></title>
            <link>https://medium.com/@ekosuprastyo15/create-a-wcf-rest-service-c-cd58452ea2e?source=rss-ddb5d4023977------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd58452ea2e</guid>
            <category><![CDATA[wcf-rest-post]]></category>
            <category><![CDATA[restful-post-csharp]]></category>
            <category><![CDATA[wcf-rest]]></category>
            <category><![CDATA[wcf-rest-csharp]]></category>
            <category><![CDATA[wcf-post-csharp]]></category>
            <dc:creator><![CDATA[Ecco Suprastyo]]></dc:creator>
            <pubDate>Fri, 21 Feb 2020 07:24:54 GMT</pubDate>
            <atom:updated>2024-01-04T02:45:38.239Z</atom:updated>
            <content:encoded><![CDATA[<p>Can WCF rest post method not allowed? sure, This article about How to create Wcf Rest Post Method Example in console application? Before that, we must know what is a RESTful api. A RESTful API is about an <strong>application program interface (API)</strong> that uses HTTP method requests to GET, PUT, POST and DELETE data.</p><p>A RESTful API — also referred to like a RESTful web service — is based on <strong>representational state transfer</strong> (REST) technology, an architectural style and approach to communications often used in web services development.</p><p>The REST technology is generally preferred for the more robust <strong>Simple Object Access Protocol (SOAP)</strong> technology because The REST leverages less bandwidth, making it to more suitable for internet usage. An API for a website is code that allows two software programs to communicate with each another . The API spells out the proper way for a developer to write a program requesting services from an operating system or other application.</p><p>The REST usually used by browsers can be thought of as the language of the internet. With cloud use on the rise, APIs are emerging to expose web services. The REST is a logical choice for building APIs that allow users to connect and interact with cloud services. RESTful APIs are used by such sites like Amazon, Google, LinkedIn and Twitter.</p><p>In this guide, I will tell you how to make <strong>WCF Rest multiple parameters post</strong> starting from making a project in Microsoft Visual Studio until testing in browser. You can also follow this instruction directly using your computer.</p><ol><li>Create new project console application with <strong>Microsoft Visual Studio 2017</strong> or etc. (<em>Example : restwcf</em>)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*JeeXieph02Dz4war3WvVig.png" /></figure><p>2. Edit file <strong><em>app.config</em></strong> like below:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;<br>&lt;configuration&gt;<br>    &lt;startup&gt; <br>        &lt;supportedRuntime version=&quot;v4.0&quot; sku=&quot;.NETFramework,Version=v4.6.1&quot; /&gt;<br>    &lt;/startup&gt;</pre><pre>&lt;system.serviceModel&gt;<br>    &lt;serviceHostingEnvironment multipleSiteBindingsEnabled=&quot;true&quot;/&gt;</pre><pre>&lt;bindings&gt;<br>      &lt;!--&lt;wsHttpBinding&gt;--&gt;<br>      &lt;basicHttpBinding&gt;<br>        &lt;binding name=&quot;basicHttp&quot; openTimeout=&quot;00:10:00&quot; closeTimeout=&quot;00:10:00&quot; sendTimeout=&quot;00:10:00&quot; receiveTimeout=&quot;01:00:00&quot; maxBufferPoolSize=&quot;2147483647&quot;&gt;<br>          &lt;security mode=&quot;None&quot;&gt;<br>            &lt;!--&lt;transport clientCredentialType=&quot;None&quot; /&gt;--&gt;<br>          &lt;/security&gt;<br>          &lt;!--&lt;reliableSession enabled=&quot;true&quot; /&gt;--&gt;<br>        &lt;/binding&gt;<br>      &lt;/basicHttpBinding&gt;<br>      &lt;!--&lt;/wsHttpBinding&gt;--&gt;</pre><pre>&lt;webHttpBinding&gt;<br>        &lt;binding name=&quot;webHttp&quot; openTimeout=&quot;00:10:00&quot; closeTimeout=&quot;00:10:00&quot; sendTimeout=&quot;00:10:00&quot; receiveTimeout=&quot;01:00:00&quot; maxBufferPoolSize=&quot;2147483647&quot;&gt;<br>          &lt;security mode=&quot;None&quot;&gt;<br>            &lt;!--&lt;transport clientCredentialType=&quot;None&quot; /&gt;--&gt;<br>          &lt;/security&gt;<br>        &lt;/binding&gt;<br>      &lt;/webHttpBinding&gt;<br>    &lt;/bindings&gt;</pre><pre>&lt;services&gt;</pre><pre>&lt;service name=&quot;restwcf.Service&quot;&gt;<br>        &lt;endpoint address =&quot;rest&quot; binding=&quot;webHttpBinding&quot; bindingConfiguration=&quot;webHttp&quot; contract=&quot;restwcf.IService&quot; behaviorConfiguration=&quot;web&quot;&gt;&lt;/endpoint&gt;<br>        &lt;host&gt;<br>          &lt;baseAddresses&gt;<br>            &lt;add baseAddress=&quot;http://localhost:8080&quot; /&gt;<br>          &lt;/baseAddresses&gt;<br>        &lt;/host&gt;<br>      &lt;/service&gt;<br>    &lt;/services&gt;</pre><pre>&lt;behaviors&gt;<br>      &lt;serviceBehaviors&gt;<br>        &lt;behavior name=&quot;mexBehaviour&quot;&gt;<br>          &lt;serviceMetadata httpGetEnabled=&quot;true&quot; httpsGetEnabled=&quot;true&quot; /&gt;<br>          &lt;!-- rest api--&gt;<br>          &lt;serviceDebug includeExceptionDetailInFaults=&quot;false&quot;/&gt;<br>        &lt;/behavior&gt;<br>      &lt;/serviceBehaviors&gt;</pre><pre>&lt;endpointBehaviors&gt;<br>        &lt;behavior name=&quot;web&quot;&gt;<br>          &lt;webHttp/&gt;<br>        &lt;/behavior&gt;<br>      &lt;/endpointBehaviors&gt;<br>    &lt;/behaviors&gt;<br>  &lt;/system.serviceModel&gt;</pre><pre>&lt;runtime&gt;<br>    &lt;assemblyBinding xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;&gt;<br>      &lt;dependentAssembly&gt;<br>        &lt;assemblyIdentity name=&quot;Newtonsoft.Json&quot; publicKeyToken=&quot;30ad4fe6b2a6aeed&quot; culture=&quot;neutral&quot; /&gt;<br>        &lt;bindingRedirect oldVersion=&quot;0.0.0.0-10.0.0.0&quot; newVersion=&quot;10.0.0.0&quot; /&gt;<br>      &lt;/dependentAssembly&gt;<br>    &lt;/assemblyBinding&gt;<br>  &lt;/runtime&gt;<br>&lt;/configuration&gt;</pre><p>3. Create <strong><em>IService.cs</em></strong> for interface class like below:</p><pre>using System;<br>using System.Collections.Generic;<br>using System.Linq;<br>using System.ServiceModel;<br>using System.ServiceModel.Web;<br>using System.Text;<br>using System.Threading.Tasks;</pre><pre>namespace restwcf<br>{<br>    [ServiceContract]<br>    public interface IService<br>    {<br>        [OperationContract]<br>        [WebInvoke(UriTemplate = &quot;postuser&quot;,<br>           ResponseFormat = WebMessageFormat.Json)]<br>        string PostUser(USER data);<br>    }</pre><pre>public class USER<br>    {<br>        public string username { get; set; }<br>        public string password { get; set; }<br>        public string firstname { get; set; }<br>        public string lastname { get; set; }<br>    }<br>}</pre><p>4. Add reference if you get any error, you need some reference like below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*eVg6YhrDnOmNCWib_5icZA.png" /></figure><p>5. After that, we need create function to give return the request. We’ll create new file with name <strong><em>Service.cs</em></strong> like below:</p><pre>using System;<br>using System.Collections.Generic;<br>using System.Linq;<br>using System.Text;<br>using System.Threading.Tasks;</pre><pre>namespace restwcf<br>{<br>    public class Service : IService<br>    {<br>        public string PostUser(USER data)<br>        {<br>            try<br>            {<br>                string result = &quot;&quot;;<br>                //Function insert database<br>                result = &quot;You have been post api with wcf restful!&quot;;<br>                return result;<br>            }<br>            catch (Exception ex)<br>            {<br>                return null;<br>            }<br>        }<br>    }<br>}</pre><p>6. The program class is a console app that is the main entry point to start the application, it configures and launches the web api host and web server using an instance of WebHostBuilder. Edit program class as below:</p><pre>using System;<br>using System.Collections.Generic;<br>using System.Linq;<br>using System.ServiceModel;<br>using System.ServiceModel.Description;<br>using System.ServiceModel.Web;<br>using System.Text;<br>using System.Threading.Tasks;</pre><pre>namespace restwcf<br>{<br>    class Program<br>    {<br>        static void Main(string[] args)<br>        {<br>            WebServiceHost hostWeb = new WebServiceHost(typeof(restwcf.Service));<br>            ServiceEndpoint ep = hostWeb.AddServiceEndpoint(typeof(restwcf.IService), new WebHttpBinding(), &quot;&quot;);<br>            ServiceDebugBehavior stp = hostWeb.Description.Behaviors.Find&lt;ServiceDebugBehavior&gt;();<br>            stp.HttpHelpPageEnabled = false;<br>            hostWeb.Open();</pre><pre>Console.WriteLine(&quot;Service Host started @ &quot; + DateTime.Now.ToString());</pre><pre>Console.Read();<br>        }<br>    }<br>}</pre><p>7. Running the application with Debug or Release mode In <strong>Microsoft visual studio 2017</strong>.</p><p>8. Testing application if already running with postman like below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0UfVBs0UZYPvZsFps6UyA.png" /></figure><p>You can see <strong>WCF Rest Post Method Example</strong> in <a href="https://github.com/eccosuprastyo/dotnet-csharp/tree/master/restwcf">Here</a>.</p><p>Thank you for reading this article about <a href="https://github.com/eccosuprastyo/dotnet-csharp/tree/master/restwcf"><strong>Create a WCF Rest Service C#</strong></a>, I hope this article is useful for you. Visit My Github about .Net Cshap in <a href="https://github.com/eccosuprastyo/dotnet-csharp">Here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd58452ea2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutorial Ecommerce App Using Flutter]]></title>
            <link>https://medium.com/@ekosuprastyo15/tutorial-ecommerce-app-using-flutter-96875d814c70?source=rss-ddb5d4023977------2</link>
            <guid isPermaLink="false">https://medium.com/p/96875d814c70</guid>
            <category><![CDATA[flutter-shopping-app]]></category>
            <category><![CDATA[flutter-ecommerse-app]]></category>
            <category><![CDATA[flutter-ecommerse]]></category>
            <category><![CDATA[flutter-ecommerse-example]]></category>
            <category><![CDATA[flutter-shopping-sample]]></category>
            <dc:creator><![CDATA[Ecco Suprastyo]]></dc:creator>
            <pubDate>Thu, 23 Jan 2020 09:30:25 GMT</pubDate>
            <atom:updated>2025-10-31T06:56:15.754Z</atom:updated>
            <content:encoded><![CDATA[<p>This tutorial will discuss about Tutorial Ecommerce App Using Flutter.Before we start to discuss about <strong>flutter ecommerce app</strong>, What is E-Commerse? <strong>E</strong>-<strong>commerce</strong> (electronic <strong>commerce</strong>) is the buying and selling of goods and services, or the transmitting of funds or data, over an electronic network, primarily the internet. These business transactions occur either as business-to-business (B2B), business-to-consumer (B2C), consumer-to-consumer or consumer-to-business.</p><p>Flutter Languague support to create E-Commerse Mobile Apps, but How to create Ecommerse App using Flutter?</p><p>So, Let’s to begin create that with follow this tutorial.</p><p>First, we must create a project using Visual Studio Code software with name “flutterecommerse”. Let’s to create a new project using Visual Studio Code:</p><ol><li>Invoke <strong>View &gt; Command Palette</strong>.</li><li>Type “flutter”, and select the <strong>Flutter: New Project</strong>.</li><li>Enter a project name, example such as “flutterecommerse”, and press <strong>Enter</strong>.</li><li>Create or select the parent directory for the new project folder.</li><li>Wait for project creation progress to complete and the main.dart file to appear.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*VXDfvwY9u-04vtyyju8pzw.png" /></figure><p>Next, add the intl and uuid package to your project. The fully <strong>pubspec.yaml</strong> file like that :</p><pre>name: flutterecommerse<br>description: A new Flutter project.</pre><pre># The following defines the version and build number for your application.<br># A version number is three numbers separated by dots, like 1.2.43<br># followed by an optional build number separated by a +.<br># Both the version and the builder number may be overridden in flutter<br># build by specifying --build-name and --build-number, respectively.<br># In Android, build-name is used as versionName while build-number used as versionCode.<br># Read more about Android versioning at <a href="https://developer.android.com/studio/publish/versioning">https://developer.android.com/studio/publish/versioning</a><br># In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.<br># Read more about iOS versioning at<br># <a href="https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html">https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html</a><br>version: 1.0.0+1</pre><pre>environment:<br>  sdk: &quot;&gt;=2.1.0 &lt;3.0.0&quot;</pre><pre>dependencies:<br>  flutter:<br>    sdk: flutter</pre><pre>  # The following adds the Cupertino Icons font to your application.<br>  # Use with the CupertinoIcons class for iOS style icons.<br>  cupertino_icons: ^0.1.2<br>  intl: ^0.15.8<br>  uuid: 2.0.0</pre><pre>dev_dependencies:<br>  flutter_test:<br>    sdk: flutter<br></pre><pre># For information on the generic Dart part of this file, see the<br># following page: <a href="https://dart.dev/tools/pub/pubspec">https://dart.dev/tools/pub/pubspec</a></pre><pre># The following section is specific to Flutter.<br>flutter:</pre><pre>  # The following line ensures that the Material Icons font is<br>  # included with your application, so that you can use the icons in<br>  # the material Icons class.<br>  uses-material-design: true</pre><pre>  # To add assets to your application, add an assets section, like this:<br>  # assets:<br>  #  - images/a_dot_burr.jpeg<br>  #  - images/a_dot_ham.jpeg</pre><pre>  # An image asset can refer to one or more resolution-specific &quot;variants&quot;, see<br>  # <a href="https://flutter.dev/assets-and-images/#resolution-aware.">https://flutter.dev/assets-and-images/#resolution-aware.</a></pre><pre>  # For details regarding adding assets from package dependencies, see<br>  # <a href="https://flutter.dev/assets-and-images/#from-packages">https://flutter.dev/assets-and-images/#from-packages</a></pre><pre>  # To add custom fonts to your application, add a fonts section here,<br>  # in this &quot;flutter&quot; section. Each entry in this list should have a<br>  # &quot;family&quot; key with the font family name, and a &quot;fonts&quot; key with a<br>  # list giving the asset and other descriptors for the font. For<br>  # example:<br>  # fonts:<br>  #   - family: Schyler<br>  #     fonts:<br>  #       - asset: fonts/Schyler-Regular.ttf<br>  #       - asset: fonts/Schyler-Italic.ttf<br>  #         style: italic<br>  #   - family: Trajan Pro<br>  #     fonts:<br>  #       - asset: fonts/TrajanPro.ttf<br>  #       - asset: fonts/TrajanPro_Bold.ttf<br>  #         weight: 700<br>  #<br>  # For details regarding fonts from package dependencies,<br>  # see <a href="https://flutter.dev/custom-fonts/#from-packages">https://flutter.dev/custom-fonts/#from-packages</a></pre><p>Then we click the get package in command palette, wait until the process is complete.</p><p>After we created <strong>pubspec.yaml</strong> , We need to create data modeling. Create a new directory in <strong><em>[projectname]/lib/[modelname]</em></strong> for models file. We will create <em>item.dart</em> with static data like below :</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:intl/intl.dart&#39;;</pre><pre>class Item {<br>  String id;<br>  String name;<br>  String description;<br>  int price;<br>  bool inStock;<br>  String imageUrl;</pre><pre>  Item(<br>      {this.id,<br>      this.name,<br>      this.description,<br>      this.price,<br>      this.inStock,<br>      this.imageUrl});</pre><pre>  String get formattedAvailability =&gt; inStock ? &quot;Available&quot; : &quot;Out of stock&quot;;<br>  String get formattedPrice =&gt; Item.formatter.format(this.price);<br>  Color get availabilityColor =&gt; inStock ? Colors.grey : Colors.red;</pre><pre>  static final formatter =<br>      NumberFormat.currency(locale: &#39;id_ID&#39;, symbol: &quot;Rp &quot;);</pre><pre>  static List&lt;Item&gt; get dummyItems =&gt; [<br>        Item(<br>            id: &quot;1&quot;,<br>            name: &quot;iPhone X (Product RED)             &quot;,<br>            description: &#39;More magical than ever.&#39;,<br>            price: 12499999,<br>            inStock: true,<br>            imageUrl:<br>                &#39;https://store.storeimages.cdn-apple.com/4982/as-images.apple.com/is/image/AppleInc/aos/published/images/i/ph/iphone/xr/iphone-xr-red-select-201809?wid=940&amp;hei=1112&amp;fmt=png-alpha&amp;qlt=80&amp;.v=1551226038669&#39;),<br>        Item(<br>            id: &quot;2&quot;,<br>            name: &quot;AirPods with Wireless Charging Case&quot;,<br>            description: &#39;More magical than ever.&#39;,<br>            price: 2999999,<br>            inStock: true,<br>            imageUrl:<br>                &#39;https://store.storeimages.cdn-apple.com/4982/as-images.apple.com/is/image/AppleInc/aos/published/images/M/RX/MRXJ2/MRXJ2?wid=1144&amp;hei=1144&amp;fmt=jpeg&amp;qlt=95&amp;op_usm=0.5%2C0.5&amp;.v=1551489675083&#39;),<br>        Item(<br>            id: &quot;3&quot;,<br>            name: &quot;iPhone X Max (GOLD)&quot;,<br>            description: &#39;More magical than ever.&#39;,<br>            price: 18999999,<br>            inStock: true,<br>            imageUrl:<br>                &#39;https://store.storeimages.cdn-apple.com/4982/as-images.apple.com/is/image/AppleInc/aos/published/images/i/ph/iphone/xs/iphone-xs-max-gold-select-2018?wid=940&amp;hei=1112&amp;fmt=png-alpha&amp;qlt=80&amp;.v=1550795409154&#39;),<br>        Item(<br>            id: &quot;4&quot;,<br>            name: &quot;iPhone X (SILVER)&quot;,<br>            description: &#39;More magical than ever.&#39;,<br>            price: 14999999,<br>            inStock: true,<br>            imageUrl:<br>                &#39;https://store.storeimages.cdn-apple.com/4982/as-images.apple.com/is/image/AppleInc/aos/published/images/i/ph/iphone/xs/iphone-xs-silver-select-2018?wid=940&amp;hei=1112&amp;fmt=png-alpha&amp;qlt=80&amp;.v=1550795411708&#39;),<br>        Item(<br>            id: &quot;5&quot;,<br>            name: &quot;iPad Pro (SPACE GRAY)&quot;,<br>            description: &#39;More magical than ever.&#39;,<br>            price: 13999999,<br>            inStock: true,<br>            imageUrl:<br>                &#39;https://store.storeimages.cdn-apple.com/4982/as-images.apple.com/is/image/AppleInc/aos/published/images/i/pa/ipad/pro/ipad-pro-11-select-cell-spacegray-201810?wid=940&amp;hei=1112&amp;fmt=png-alpha&amp;qlt=80&amp;.v=1540591731427&#39;),<br>        Item(<br>            id: &quot;6&quot;,<br>            name: &quot;Apple Watch Silver Aluminum (44 mm)&quot;,<br>            description: &#39;More magical than ever.&#39;,<br>            price: 8999999,<br>            inStock: false,<br>            imageUrl:<br>                &#39;https://store.storeimages.cdn-apple.com/4982/as-images.apple.com/is/image/AppleInc/aos/published/images/4/4/44/alu/44-alu-silver-sport-white-s4-1up?wid=940&amp;hei=1112&amp;fmt=png-alpha&amp;qlt=80&amp;.v=1539190366920&#39;),<br>      ];<br>}</pre><p>Later, create <em>shopping_cart.dart</em> as item will be buy :</p><pre>import &#39;item.dart&#39;;<br>import &#39;package:uuid/uuid.dart&#39;;</pre><pre>class ShoppingCart {<br>  final orderId = Uuid().v4();</pre><pre>  List&lt;Item&gt; items = [];</pre><pre>  bool get isEmpty =&gt; items.isEmpty;<br>  int get numOfItems =&gt; items.length;</pre><pre>  int get totalPrice {<br>    int totalPrice = 0;<br>    items.forEach((i) {<br>      totalPrice += i.price;<br>    });<br>    return totalPrice;<br>  }</pre><pre>  String get formattedTotalPrice {<br>    if (isEmpty) {<br>      return Item.formatter.format(0);<br>    }</pre><pre>    return Item.formatter.format(this.totalPrice);<br>  }</pre><pre>  bool isExists(item) {<br>    if (items.isEmpty) {<br>      return false;<br>    }<br>    final indexOfItem = items.indexWhere((i) =&gt; item.id == i.id);<br>    return indexOfItem &gt;= 0;<br>  }</pre><pre>  void add(Item item) {<br>    if (items.isEmpty) {<br>      items.add(item);<br>      return;<br>    }</pre><pre>    if (!this.isExists(item)) {<br>      items.add(item);<br>    }<br>  }</pre><pre>  void remove(Item item) {<br>    if (items.isEmpty) return;</pre><pre>    final indexOfItem = items.indexWhere((i) =&gt; item.id == i.id);<br>    if (indexOfItem &gt;= 0) {<br>      items.removeAt(indexOfItem);<br>    }<br>  }</pre><pre>  Map&lt;String, dynamic&gt; get toMap {<br>    final List&lt;Map&lt;String, dynamic&gt;&gt; items = this<br>        .items<br>        .map((i) =&gt; {<br>              &#39;id&#39;: i.id,<br>              &#39;name&#39;: i.name,<br>              &#39;description&#39;: i.description,<br>              &#39;price&#39;: i.price,<br>              &#39;inStock&#39;: i.inStock,<br>              &#39;imageUrl&#39;: i.imageUrl<br>            })<br>        .toList();</pre><pre>    return {&quot;orderId&quot;: this.orderId, &quot;items&quot;: items, &quot;total&quot;: this.totalPrice};<br>  }<br>}</pre><p>And then, we need services class to process items if do enter the list cart some items until checkout. So, we create display classes items like below :</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;cart_list.dart&#39;;<br>import &#39;models/shopping_cart.dart&#39;;<br>import &#39;models/item.dart&#39;;</pre><pre>class ShopListWidget extends StatefulWidget {<br>  @override<br>  State&lt;StatefulWidget&gt; createState() {<br>    return _ShopListState();<br>  }<br>}</pre><pre>class _ShopListState extends State&lt;ShopListWidget&gt; {<br>  ShoppingCart cart = ShoppingCart();</pre><pre>  final _scaffoldKey = GlobalKey&lt;ScaffoldState&gt;();<br>  final List&lt;Item&gt; items = Item.dummyItems;</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    final columnCount =<br>        MediaQuery.of(context).orientation == Orientation.portrait ? 2 : 4;</pre><pre>    final width = MediaQuery.of(context).size.width / columnCount;<br>    const height = 400;</pre><pre>    List&lt;Widget&gt; items = [];<br>    for (var x = 0; x &lt; this.items.length; x++) {<br>      bool isSideLine;<br>      if (columnCount == 2) {<br>        isSideLine = x % 2 == 0;<br>      } else {<br>        isSideLine = x % 4 != 3;<br>      }<br>      final item = this.items[x];</pre><pre>      items.add(_ShopListItem(<br>        item: item,<br>        isInCart: cart.isExists(item),<br>        isSideLine: isSideLine,<br>        onTap: (item) {<br>          _scaffoldKey.currentState.hideCurrentSnackBar();</pre><pre>          if (cart.isExists(item)) {<br>            cart.remove(item);<br>            _scaffoldKey.currentState.showSnackBar(SnackBar(<br>              content: Text(&#39;Item is removed from cart!&#39;),<br>            ));<br>          } else if (item.inStock) {<br>            cart.add(item);<br>            _scaffoldKey.currentState.showSnackBar(SnackBar(<br>              content: Text(&#39;Item is added to cart!&#39;),<br>            ));<br>          } else {<br>            _scaffoldKey.currentState.showSnackBar(SnackBar(<br>              content: Text(&#39;Item is out of stock!&#39;),<br>            ));<br>          }<br>          this.setState(() {});<br>        },<br>      ));<br>    }</pre><pre>    return Scaffold(<br>        key: _scaffoldKey,<br>        appBar: AppBar(<br>          title: Text(&quot;Apple Store&quot;),<br>        ),<br>        body: GridView.count(<br>          childAspectRatio: width / height,<br>          scrollDirection: Axis.vertical,<br>          crossAxisCount: columnCount,<br>          children: items,<br>        ),<br>        floatingActionButton: cart.isEmpty<br>            ? null<br>            : FloatingActionButton.extended(<br>                onPressed: () {<br>                  Navigator.of(context).push(MaterialPageRoute(<br>                      builder: (context) =&gt; CartListWidget(<br>                            cart: this.cart,<br>                          )));<br>                },<br>                icon: Icon(Icons.shopping_cart),<br>                label: Text(&quot;${cart.numOfItems}&quot;),<br>              ));<br>  }<br>}</pre><pre>class _ShopListItem extends StatelessWidget {<br>  final Item item;<br>  final bool isInCart;<br>  final bool isSideLine;<br>  dynamic onTap;</pre><pre>  _ShopListItem({this.item, this.isInCart, this.isSideLine, this.onTap});</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    Border border;<br>    if (isSideLine) {<br>      border = Border(<br>          bottom: BorderSide(color: Colors.grey, width: 0.5),<br>          right: BorderSide(color: Colors.grey, width: 0.5));<br>    } else {<br>      border = Border(bottom: BorderSide(color: Colors.grey, width: 0.5));<br>    }</pre><pre>    return InkWell(<br>        onTap: () =&gt; this.onTap(item),<br>        child: Container(<br>            decoration: BoxDecoration(border: border),<br>            child: Column(<br>              crossAxisAlignment: CrossAxisAlignment.center,<br>              children: &lt;Widget&gt;[<br>                Padding(<br>                  padding: EdgeInsets.only(top: 16),<br>                ),<br>                Container(<br>                  child: AspectRatio(<br>                    aspectRatio: 1,<br>                    child: Image.network(item.imageUrl),<br>                  ),<br>                  height: 250,<br>                ),<br>                Padding(<br>                  padding: EdgeInsets.only(top: 16),<br>                ),<br>                Text(item.name,<br>                    textAlign: TextAlign.center,<br>                    style: Theme.of(context)<br>                        .textTheme<br>                        .title<br>                        .apply(fontSizeFactor: 0.8)),<br>                Padding(<br>                  padding: EdgeInsets.only(top: 16),<br>                ),<br>                Text(item.formattedPrice,<br>                    textAlign: TextAlign.center,<br>                    style: Theme.of(context)<br>                        .textTheme<br>                        .subhead<br>                        .apply(fontSizeFactor: 0.8)),<br>                Padding(<br>                  padding: EdgeInsets.only(top: 16),<br>                ),<br>                Text(this.isInCart ? &quot;In Cart&quot; : item.formattedAvailability,<br>                    textAlign: TextAlign.center,<br>                    style: Theme.of(context).textTheme.caption.apply(<br>                        fontSizeFactor: 0.8,<br>                        color:<br>                            isInCart ? Colors.blue : item.availabilityColor)),<br>              ],<br>            )));<br>  }<br>}</pre><p>And create <em>cart_list.dart</em> to display items checkout :</p><pre>import &#39;dart:async&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter/services.dart&#39;;<br>import &#39;models/shopping_cart.dart&#39;;<br>import &#39;models/item.dart&#39;;</pre><pre>class CartListWidget extends StatefulWidget {<br>  final ShoppingCart cart;</pre><pre>  CartListWidget({this.cart});</pre><pre>  @override<br>  State&lt;StatefulWidget&gt; createState() {<br>    return _CartListWidgetState();<br>  }<br>}</pre><pre>class _CartListWidgetState extends State&lt;CartListWidget&gt; {<br>  static const platform = const MethodChannel(&#39;camellabs.com/payment&#39;);</pre><pre>  Future&lt;void&gt; _checkout() async {<br>    await platform.invokeMethod(&#39;charge&#39;, widget.cart.toMap);<br>  }</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    List&lt;Widget&gt; items = [];</pre><pre>    widget.cart.items.forEach((c) {<br>      items.add(_CartListItemWidget(<br>        item: c,<br>      ));<br>      items.add(Padding(<br>        padding: EdgeInsets.only(top: 8.0),<br>      ));<br>    });</pre><pre>    return Scaffold(<br>        appBar: AppBar(<br>          title: Text(&#39;My Cart&#39;),<br>          actions: &lt;Widget&gt;[<br>            FlatButton(<br>              textColor: Colors.white,<br>              onPressed: () =&gt; this._checkout(),<br>              child: Text(&quot;Checkout&quot;),<br>            )<br>          ],<br>        ),<br>        body: Container(<br>            decoration: BoxDecoration(color: Color(0xfff0eff4)),<br>            child: Stack(<br>              children: &lt;Widget&gt;[<br>                ListView(<br>                  padding: EdgeInsets.only(bottom: 64),<br>                  children: items,<br>                ),<br>                Positioned(<br>                  bottom: 0,<br>                  left: 0,<br>                  right: 0,<br>                  height: 64,<br>                  child: _CartListSummaryFooterWidget(<br>                    totalPrice: widget.cart.formattedTotalPrice,<br>                  ),<br>                )<br>              ],<br>            )));<br>  }<br>}</pre><pre>class _CartListSummaryFooterWidget extends StatelessWidget {<br>  final String totalPrice;</pre><pre>  _CartListSummaryFooterWidget({this.totalPrice});</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return Container(<br>        decoration: BoxDecoration(<br>            color: Color(0XFFF4F4F4),<br>            border: Border(top: BorderSide(color: Colors.grey, width: 0.5))),<br>        child: Padding(<br>          padding: EdgeInsets.all(16.0),<br>          child: Center(<br>              child: Row(<br>            children: &lt;Widget&gt;[<br>              Text(<br>                &#39;Total&#39;,<br>                textAlign: TextAlign.left,<br>                style: Theme.of(context).textTheme.title,<br>              ),<br>              Expanded(<br>                  child: Text(<br>                this.totalPrice,<br>                textAlign: TextAlign.right,<br>                style: Theme.of(context).textTheme.subhead,<br>              ))<br>            ],<br>          )),<br>        ));<br>  }<br>}</pre><pre>class _CartListItemWidget extends StatelessWidget {<br>  final Item item;</pre><pre>  _CartListItemWidget({this.item});</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return Container(<br>      decoration: BoxDecoration(<br>          color: Colors.white,<br>          border: Border(<br>              top: BorderSide(color: Colors.grey, width: 0.5),<br>              bottom: BorderSide(color: Colors.grey, width: 0.5))),<br>      padding: EdgeInsets.all(16.0),<br>      child: Row(<br>        children: &lt;Widget&gt;[<br>          Container(<br>            height: 64,<br>            child: AspectRatio(<br>              aspectRatio: 1,<br>              child: Image.network(item.imageUrl),<br>            ),<br>          ),<br>          Padding(<br>            padding: EdgeInsets.only(right: 8.0),<br>          ),<br>          Expanded(<br>              child: Text(<br>            item.name,<br>            style:<br>                Theme.of(context).textTheme.title.apply(fontSizeFactor: 0.75),<br>          )),<br>          Padding(<br>            padding: EdgeInsets.only(right: 8.0),<br>          ),<br>          Text(<br>            item.formattedPrice,<br>            textAlign: TextAlign.right,<br>            style: Theme.of(context).textTheme.subhead,<br>          )<br>        ],<br>      ),<br>    );<br>  }<br>}</pre><p>The last step, we create main.dart like below :</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;shop_list.dart&#39;;</pre><pre>void main() =&gt; runApp(MyApp());</pre><pre>class MyApp extends StatelessWidget {</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;ShopX&#39;,<br>      debugShowCheckedModeBanner: false,<br>      theme: ThemeData(<br>        primarySwatch: Colors.blue,<br>      ),<br>      home: ShopListWidget(),<br>    );<br>  }<br>}</pre><p>The application can be run to show output below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*VNEPW2xtYCxVwWRglcSbHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*nNgeffXYSHslHVqtOcX86w.png" /></figure><p>For complete source code you can see flutter ecommerce github in <a href="https://github.com/eccosuprastyo/flutter/tree/master/flutterecommerse">Here</a>.</p><p>Thank you for reading this article about <strong>Flutter Ecommerce Example</strong>, I hope this article is useful for you. Visit My Github about Flutter in <a href="https://github.com/eccosuprastyo/flutter">Here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96875d814c70" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[QR Code Generator And Scanner Flutter]]></title>
            <link>https://medium.com/@ekosuprastyo15/qr-code-generator-and-scanner-flutter-bd69eaa504a6?source=rss-ddb5d4023977------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd69eaa504a6</guid>
            <category><![CDATA[qrcode-flutter]]></category>
            <category><![CDATA[scanner-qrcode-flutter]]></category>
            <category><![CDATA[barcode-flutter]]></category>
            <category><![CDATA[generate-qrcode-flutter]]></category>
            <category><![CDATA[flutter-qr]]></category>
            <dc:creator><![CDATA[Ecco Suprastyo]]></dc:creator>
            <pubDate>Thu, 26 Dec 2019 04:32:25 GMT</pubDate>
            <atom:updated>2025-10-31T06:56:23.125Z</atom:updated>
            <content:encoded><![CDATA[<p>The Example will show about <strong>QR Code Generator And Scanner Flutter.</strong> This article will creating a simple application using <a href="https://pub.dev/packages/qr_flutter#-readme-tab-"><strong>qr_flutter 3.1.0 package</strong></a>. The <strong>qr_flutter 3.1.0 package</strong> have features like that :</p><ul><li>Built on <a href="https://github.com/kevmoo/qr.dart">QR — Dart</a></li><li>Automatic QR code version/type detection or manual entry</li><li>Supports QR code versions 1–40</li><li>Error correction / redundancy</li><li>Configurable output size, padding, background and foreground colors</li><li>Supports image overlays</li><li>Export to image data to save to file or use in memory</li><li>No internet connection required</li></ul><p>You can read other article with flutter in this section :</p><ul><li><a href="http://camellabs.com/flutter-sqlite-crud-example-form/"><strong>Flutter Sqlite Crud Example Form</strong></a></li><li><a href="http://camellabs.com/how-to-create-listview-in-flutter-dynamic/">How To Create Listview in Flutter Dynamic</a></li></ul><p>First, we must create a project using Visual Studio Code software with name “barcode_scanner”. Let’s to create a new project using Visual Studio Code:</p><ol><li>Invoke <strong>View &gt; Command Palette</strong>.</li><li>Type “flutter”, and select the <strong>Flutter: New Project</strong>.</li><li>Enter a project name, example such as “barcode_scanner”, and press <strong>Enter</strong>.</li><li>Create or select the parent directory for the new project folder.</li><li>Wait for project creation progress to complete and the main.dart file to appear.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*VXDfvwY9u-04vtyyju8pzw.png" /></figure><p>Next, add the <a href="https://pub.dev/packages/image_picker">qr_flutter</a> package to your project. The qr_flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter.</p><pre>dependencies: <br>qr_flutter: &lt;latest_version&gt;</pre><p>Then we click the get package, wait until the process is complete.</p><p>After we created <strong>pubspec.yaml</strong> , You must edit file with name <strong>main.dart </strong>like below :</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;home_screen.dart&#39;;</pre><pre>void main() =&gt; runApp(MyApp());</pre><pre>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      debugShowCheckedModeBanner: false,<br>      title: &#39;QR Generator-Scanner&#39;,<br>      theme: ThemeData(<br>        primarySwatch: Colors.blue,<br>      ),<br>      home: HomeScreen(),<br>    );<br>  }<br>}</pre><p>We will create <strong>home_screen.dart</strong> to default screen, Our home screen can be allow the user to select scan or generate QR Code by tapping on button. The widget will return a Column with 2 RaisedButton as the children, one of routing to generating QR code screen and one of routing to scanning QR code screen when the button is tapped. The home screen code like below:</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:barcode_scanner/scan.dart&#39;;<br>import &#39;package:barcode_scanner/generate.dart&#39;;<br>import &#39;package:flutter/rendering.dart&#39;;</pre><pre>class HomeScreen extends StatelessWidget {</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>        appBar: AppBar(<br>          centerTitle: true,<br>          title: Text(&#39;QR Code Scanner &amp; Generator&#39;),<br>          backgroundColor: Colors.deepOrange,<br>        ),<br>        body: Center(<br>            child:<br>              Column(<br>                mainAxisAlignment: MainAxisAlignment.center,<br>                crossAxisAlignment: CrossAxisAlignment.stretch,<br>                children: &lt;Widget&gt;[<br>                  Padding(<br>                      padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),<br>                      child: RaisedButton(<br>                          color: Colors.deepOrange,<br>                          textColor: Colors.white,<br>                          splashColor: Colors.blueGrey,<br>                          onPressed: () {<br>                            Navigator.push(<br>                              context,<br>                              MaterialPageRoute(builder: (context) =&gt; ScanScreen()),<br>                            );<br>                          },<br>                          child: const Text(&#39;SCAN QR CODE&#39;)<br>                      ),<br>                    ),<br>                   Padding(<br>                      padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),<br>                      child: RaisedButton(<br>                          color: Colors.deepOrange,<br>                          textColor: Colors.white,<br>                          splashColor: Colors.blueGrey,<br>                          onPressed: () {<br>                            Navigator.push(<br>                              context,<br>                              MaterialPageRoute(builder: (context) =&gt; GenerateScreen()),<br>                            );<br>                          },<br>                          child: const Text(&#39;GENERATE QR CODE&#39;)<br>                      ),<br>                    ),<br>                ],<br>              )<br>          ),<br>        );<br>  }<br>}</pre><p>For detail widget we need create <strong>detail.dart</strong> :</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter/services.dart&#39;;</pre><pre>import &#39;dart:io&#39;;<br>import &#39;dart:async&#39;;</pre><pre>class DetailWidget extends StatefulWidget  {</pre><pre>  String _filePath;<br>  DetailWidget(this._filePath);</pre><pre>  @override<br>  State&lt;StatefulWidget&gt; createState() {<br>    return _DetailState();<br>  }</pre><pre>}</pre><pre>class _DetailState extends State&lt;DetailWidget&gt; {</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(&#39;Detail&#39;),<br>        actions: &lt;Widget&gt;[<br>          IconButton(<br>            icon: Icon(Icons.share),<br>            onPressed: () {</pre><pre>              final channel = const MethodChannel(&#39;channel:me.camellabs.share/share&#39;);<br>              channel.invokeMethod(&#39;shareFile&#39;, &#39;image.png&#39;);</pre><pre>            },<br>          )</pre><pre>        ],<br>      ),<br>      body: Container(<br>    child: SizedBox(<br>    height: 500.0,<br>      child: new Center(<br>        child: widget._filePath == null<br>            ? Text(&#39;No Image&#39;)<br>            : Container(<br>            child: Image.file(File(widget._filePath), fit: BoxFit.fitWidth))<br>        ),<br>      ),<br>    )<br>    );</pre><pre>  }</pre><pre>}</pre><p>Create <strong>scan screen</strong> widget display the start scan with camera button and a Text widget that display the result of the camera QR code scan. It uses the Column Widget as the parent for the Text and Button children.</p><pre>import &#39;dart:async&#39;;</pre><pre>import &#39;package:barcode_scan/barcode_scan.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter/services.dart&#39;;</pre><pre>class ScanScreen extends StatefulWidget {<br>  @override<br>  _ScanState createState() =&gt; new _ScanState();<br>}</pre><pre>class _ScanState extends State&lt;ScanScreen&gt; {<br>  String barcode = &quot;&quot;;</pre><pre>  @override<br>  initState() {<br>    super.initState();<br>  }</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>        appBar: new AppBar(<br>          title: new Text(&#39;QR Code Scanner&#39;),<br>          backgroundColor: Colors.deepOrange,<br>        ),<br>        body: new Center(<br>          child: new Column(<br>            mainAxisAlignment: MainAxisAlignment.center,<br>            crossAxisAlignment: CrossAxisAlignment.stretch,<br>            children: &lt;Widget&gt;[<br>              Padding(<br>                padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),<br>                child: RaisedButton(<br>                    color: Colors.deepOrange,<br>                    textColor: Colors.white,<br>                    splashColor: Colors.blueGrey,<br>                    onPressed: scan,<br>                    child: const Text(&#39;START CAMERA SCAN&#39;)<br>                ),<br>              )<br>              ,<br>              Padding(<br>                padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),<br>                child: Text(barcode, textAlign: TextAlign.center,),<br>              )<br>              ,<br>            ],<br>          ),<br>        ));<br>  }</pre><pre>  Future scan() async {<br>    try {<br>      String barcode = await BarcodeScanner.scan();<br>      setState(() =&gt; this.barcode = barcode);<br>    } on PlatformException catch (e) {<br>      if (e.code == BarcodeScanner.CameraAccessDenied) {<br>        setState(() {<br>          this.barcode = &#39;The user did not grant the camera permission!&#39;;<br>        });<br>      } else {<br>        setState(() =&gt; this.barcode = &#39;Unknown error: $e&#39;);<br>      }<br>    } on FormatException{<br>      setState(() =&gt; this.barcode = &#39;null (User returned using the &quot;back&quot;-button before scanning anything. Result)&#39;);<br>    } catch (e) {<br>      setState(() =&gt; this.barcode = &#39;Unknown error: $e&#39;);<br>    }<br>  }<br>}</pre><p>Create <strong>Generate screen</strong> widget displays a TextField for user enter the text data that will be used to generate the QR Code widget using the qr_flutter plugin when the user tap on the submit Button. It also provides a Share Button in the Navigation bar to share the image png file to other apps in iOS and Android.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:qr_flutter/qr_flutter.dart&#39;;<br>import &#39;package:flutter/services.dart&#39;;<br>import &#39;dart:async&#39;;<br>import &#39;dart:typed_data&#39;;<br>import &#39;dart:ui&#39;;<br>import &#39;dart:io&#39;;<br>import &#39;package:flutter/rendering.dart&#39;;<br>import &#39;package:path_provider/path_provider.dart&#39;;</pre><pre>class GenerateScreen extends StatefulWidget {</pre><pre>  @override<br>  State&lt;StatefulWidget&gt; createState() =&gt; GenerateScreenState();<br>}</pre><pre>class GenerateScreenState extends State&lt;GenerateScreen&gt; {</pre><pre>  static const double _topSectionTopPadding = 50.0;<br>  static const double _topSectionBottomPadding = 20.0;<br>  static const double _topSectionHeight = 50.0;</pre><pre>  GlobalKey globalKey = new GlobalKey();<br>  String _dataString = &quot;Hello from this QR&quot;;<br>  String _inputErrorText;<br>  final TextEditingController _textController =  TextEditingController();</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(&#39;QR Code Generator&#39;),<br>        backgroundColor: Colors.deepOrange,<br>        actions: &lt;Widget&gt;[<br>          IconButton(<br>            icon: Icon(Icons.share),<br>            onPressed: _captureAndSharePng,<br>          )<br>        ],<br>      ),<br>      body: _contentWidget(),<br>    );<br>  }</pre><pre>  Future&lt;void&gt; _captureAndSharePng() async {<br>    try {<br>      RenderRepaintBoundary boundary = globalKey.currentContext.findRenderObject();<br>      var image = await boundary.toImage();<br>      ByteData byteData = await image.toByteData(format: ImageByteFormat.png);<br>      Uint8List pngBytes = byteData.buffer.asUint8List();</pre><pre>      final tempDir = await getTemporaryDirectory();<br>      final file = await new File(&#39;${tempDir.path}/image.png&#39;).create();<br>      await file.writeAsBytes(pngBytes);</pre><pre>      final channel = const MethodChannel(&#39;channel:me.camellabs.share/share&#39;);<br>      channel.invokeMethod(&#39;shareFile&#39;, &#39;image.png&#39;);</pre><pre>    } catch(e) {<br>      print(e.toString());<br>    }<br>  }</pre><pre>  _contentWidget() {<br>    final bodyHeight = MediaQuery.of(context).size.height - MediaQuery.of(context).viewInsets.bottom;<br>    return  Container(<br>      color: const Color(0xFFFFFFFF),<br>      child:  Column(<br>        children: &lt;Widget&gt;[<br>          Padding(<br>            padding: const EdgeInsets.only(<br>              top: _topSectionTopPadding,<br>              left: 20.0,<br>              right: 10.0,<br>              bottom: _topSectionBottomPadding,<br>            ),<br>            child:  Container(<br>              height: _topSectionHeight,<br>              child:  Row(<br>                mainAxisSize: MainAxisSize.max,<br>                crossAxisAlignment: CrossAxisAlignment.stretch,<br>                children: &lt;Widget&gt;[<br>                  Expanded(<br>                    child:  TextField(<br>                      controller: _textController,<br>                      decoration:  InputDecoration(<br>                        hintText: &quot;Enter a custom message&quot;,<br>                        errorText: _inputErrorText,<br>                      ),<br>                    ),<br>                  ),<br>                  Padding(<br>                    padding: const EdgeInsets.only(left: 10.0),<br>                    child:  FlatButton(<br>                      child:  Text(&quot;SUBMIT&quot;),<br>                      onPressed: () {<br>                        setState((){<br>                          _dataString = _textController.text;<br>                          _inputErrorText = null;<br>                        });<br>                      },<br>                    ),<br>                  )<br>                ],<br>              ),<br>            ),<br>          ),<br>          Expanded(<br>            child:  Center(<br>              child: RepaintBoundary(<br>                key: globalKey,<br>                child: QrImage(<br>                  data: _dataString,<br>                  size: 0.5 * bodyHeight,<br>                  <br>                ),<br>              ),<br>            ),<br>          ),<br>        ],<br>      ),<br>    );<br>  }<br>}</pre><p>The application can be run to show output below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*0HePfShCPkBqdn1XepxheA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*C7ZMt5J_H3UF2YWcjdCufQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*eLtOMHAD5CwzqvrKMO1FTQ.png" /></figure><p>For complete source code you can see flutter qr code scanner in <a href="https://github.com/eccosuprastyo/flutter/tree/master/barcode_scanner">Here</a>.</p><p>Thank you for reading this article about <strong>QR Code Generator And Scanner Flutter</strong>, I hope this article is useful for you. Visit My Github about Flutter in <a href="https://github.com/eccosuprastyo/flutter">Here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd69eaa504a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Use Delegates With Threads in C#]]></title>
            <link>https://medium.com/@ekosuprastyo15/how-to-use-delegates-with-threads-in-c-45039eef646?source=rss-ddb5d4023977------2</link>
            <guid isPermaLink="false">https://medium.com/p/45039eef646</guid>
            <category><![CDATA[csharp-delegates-example]]></category>
            <category><![CDATA[invoke-delegates-threads]]></category>
            <category><![CDATA[delegates-in-threads]]></category>
            <category><![CDATA[csharp-threads]]></category>
            <category><![CDATA[csharp-delegates]]></category>
            <dc:creator><![CDATA[Ecco Suprastyo]]></dc:creator>
            <pubDate>Tue, 10 Dec 2019 07:56:32 GMT</pubDate>
            <atom:updated>2025-10-31T06:56:33.026Z</atom:updated>
            <content:encoded><![CDATA[<p>This article learn about <strong>How To Use Delegates With Threads in C#</strong>,this tutorial explains how to invoke delegate application with Threading. Here we will discuss step by step to create a console application using the C# programming language. Delegates is a type that represents references to methods with a particular parameter list and return type. When you instantiate a delegate, you can associate its instance with any method with a compatible signature and return type. You can invoke (or call) the method through the delegate instance. You can read more about Delegates in <a href="https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/">Here</a>.</p><p>For that let us immediately practice this tutorial with detail instructions below:</p><ol><li>Create a new application project. In Visual Studio, on the menu click File&gt; New &gt; Project. For more details, see the following menu on the display.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*RKEHo-efRxzy6cNp8omZ1Q.png" /></figure><p>2. Then will appear the window New Project like the look below and you can select “<em>Console Application</em>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*U626cy_l088X4A1upMbp4A.png" /></figure><p>3. Edit Program.cs in when project created like below :</p><pre>using System;<br>using System.Collections.Generic;<br>using System.Linq;<br>using System.Text;<br>using System.Threading;<br>using System.Threading.Tasks;</pre><pre>namespace delegates<br>{<br>    class Program<br>    {<br>        static void Main(string[] args)<br>        {<br>            Thread summary = new Thread(o =&gt; { example.ThreadCalculate(); }); summary.Start();<br>        }<br>    }<br>}</pre><p>You start a thread by supplying a function that represents the method and the thread is to execute in its class constructor. You then call the <a href="https://docs.microsoft.com/en-us/dotnet/api/system.threading.thread.start?view=netframework-4.8">Start</a> method to begin execution.</p><p>4. Next step, create new class item with name “example.cs” and write code like below :</p><pre>using System;<br>using System.Collections.Generic;<br>using System.Linq;<br>using System.Text;<br>using System.Threading.Tasks;</pre><pre>namespace delegates<br>{<br>    class example<br>    {<br>        internal delegate void ThreadSummary(int val1, int val2);</pre><pre>        public static void ThreadCalculate()<br>        {<br>            while (true)<br>            {<br>                Console.WriteLine(&quot;==========Summary===========&quot;);<br>                string val1;<br>                string val2;<br>                Console.Write(&quot;Enter first integer: &quot;);<br>                val1 = Console.ReadLine();<br>                Console.Write(&quot;Enter second integer: &quot;);<br>                val2 = Console.ReadLine();</pre><pre>                ThreadSummary sum = new ThreadSummary(ProcessSummary);<br>                sum.Invoke(Convert.ToInt32(val1), Convert.ToInt32(val2));<br>            }<br>        }</pre><pre>        internal static void ProcessSummary(int val1, int val2)<br>        {<br>            int result = val1 + val2;<br>            Console.WriteLine(&quot;Your Summary Input: {0}&quot;, result);<br>            Console.WriteLine(&quot;============================&quot;);<br>        }<br>    }<br>}</pre><p>5. After you write down the program listings, press the F5 key to run the program and if you successfull the result is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*YeRafSKIUM1i8MPPRtLkjQ.png" /></figure><p>We have explained how to make a program <strong>How To Use Delegates With Threads in C#</strong>, for those of you who want to download the source code of the program also can. Hopefully this discussion is helpful to you.</p><p>You can see <a href="https://camellabs.com/how-to-use-delegates-with-threads-in-csharp/"><strong>How To Use Delegates With Threads in C# </strong></a>from Github project in <a href="https://github.com/eccosuprastyo/dotnet-csharp/tree/master/delegates">Here</a>.</p><p>Thank you for reading this article about Delegate in thread C#, I hope this article is useful for you. Visit My Github about .Net Csharp in <a href="https://github.com/eccosuprastyo/dotnet-csharp">Here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45039eef646" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ASP .Net Core Upload File With Progress Bar]]></title>
            <link>https://medium.com/@ekosuprastyo15/asp-net-core-upload-file-with-progress-bar-f4c10247e779?source=rss-ddb5d4023977------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4c10247e779</guid>
            <category><![CDATA[aspnetcore-progress-bar]]></category>
            <category><![CDATA[net-core-upload-excel]]></category>
            <category><![CDATA[aspnet-core-upload-file]]></category>
            <category><![CDATA[csharp-upload-file]]></category>
            <category><![CDATA[progress-bar-bootstrap]]></category>
            <dc:creator><![CDATA[Ecco Suprastyo]]></dc:creator>
            <pubDate>Thu, 28 Nov 2019 04:33:55 GMT</pubDate>
            <atom:updated>2025-10-31T06:56:41.009Z</atom:updated>
            <content:encoded><![CDATA[<h3>ASP .Net Core Upload File With Progress Bar</h3><p>This article about <strong>ASP .Net Core Upload File With Progress Bar</strong>. Examples using Bootstrap custom progress bars featuring support like stacked bars, animated backgrounds, and text labels.</p><p>Progress components are built with two HTML elements, some CSS to set the width, and a few attributes. We don’t use <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress">the HTML5 </a><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress">&lt;progress&gt; element</a>, ensuring you can stack progress bars, animate them, and place text labels over them.</p><ul><li>We use the .progress as a wrapper to indicate the max value of the progress bar.</li><li>We use the inner .progress-bar to indicate the progress so far.</li><li>The .progress-bar requires an inline style, utility class, or custom CSS to set their width.</li><li>The .progress-bar also requires some role and aria attributes to make it accessible.</li></ul><p>In this guide, I will tell you how to make <strong>ASP .Net Core Upload File With Progress Bar</strong> starting from making a project in Microsoft Visual Studio until testing in browser. You can also follow this instruction directly using your computer.</p><ol><li>Create new project .net core application with <strong>Microsoft Visual Studio 2017</strong> or etc. (<em>Example : upload_file</em>)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*1Vw5WATrr4Ij4bTLOVB_zg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*VBAWoup0Z3wzNbHm9u4dcw.png" /></figure><p>2. Edit file views <em>index.cshtml</em> in <em>Views/Home Folder</em> like below :</p><pre>@{<br>    ViewData[&quot;Title&quot;] = &quot;Home Page&quot;;<br>}</pre><pre>&lt;p&gt;<br>    &lt;h4&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;UPLOAD FILE EXAMPLE&lt;/b&gt;&lt;/h4&gt;<br>&lt;/p&gt;<br>&lt;hr /&gt;<br>&lt;br /&gt;</pre><pre>&lt;form id=&quot;form&quot; name=&quot;form&quot; enctype=&quot;multipart/form-data&quot; method=&quot;post&quot;&gt;<br>    &lt;div class=&quot;buttons&quot;&gt;<br>        &lt;div class=&quot;upload-button&quot;&gt;<br>            &lt;input id=&quot;files&quot; name=&quot;files&quot; type=&quot;file&quot; /&gt;&lt;br /&gt;&lt;button type=&quot;button&quot; class=&quot;btn btn-info&quot; onclick=&quot;uploadFiles(&#39;files&#39;);&quot;&gt;Upload&lt;/button&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/form&gt;</pre><pre>&lt;br /&gt;<br>&lt;div class=&quot;progress&quot;&gt;<br>    &lt;div id=&quot;progress&quot; class=&quot;progress-bar progress-bar-striped progress-bar-animated&quot; role=&quot;progressbar&quot; aria-valuenow=&quot;25&quot; aria-valuemin=&quot;0&quot; aria-valuemax=&quot;100&quot; style=&quot;width: 0%;&quot;&gt;<br>        &lt;div id=&quot;label&quot; class=&quot;control-label&quot;&gt;0%&lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><pre>&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;</pre><pre>    var isUpload = true;<br>    function uploadFiles(inputId) {<br>        isUpload = false;<br>        var input = document.getElementById(inputId);<br>        var files = input.files;<br>        var formData = new FormData();</pre><pre>        for (var i = 0; i != files.length; i++) {<br>            formData.append(&quot;files&quot;, files[i]);<br>        }</pre><pre>        startUpdatingProgressIndicator();<br>        $.ajax(<br>            {<br>                url: &quot;/Home/upload&quot;,<br>                data: formData,<br>                processData: false,<br>                contentType: false,<br>                type: &quot;POST&quot;,<br>                success: function (data) {<br>                    if (data[&#39;message&#39;] === &quot;Data Uploaded Successfully!&quot;) {<br>                        alert(&quot;Data Uploaded Successfully!&quot;);<br>                        stopUpdatingProgressIndicator();<br>                    }<br>                    else {<br>                        alert(data[&#39;message&#39;]);<br>                        stopUpdatingProgressIndicator();<br>                    }<br>                    isUpload = true;<br>                }<br>            }<br>        );<br>    }</pre><pre>    var intervalId;</pre><pre>    function startUpdatingProgressIndicator() {<br>        $(&quot;#progress&quot;).show();</pre><pre>        intervalId = setInterval(<br>            function () {<br>                // We use the POST requests here to avoid caching problems (we could use the GET requests and disable the cache instead)<br>                $.post(<br>                    &quot;/Home/progress&quot;,<br>                    function (progress) {<br>                        //$(&quot;#bar&quot;).css({ width: progress + &quot;%&quot; });<br>                        $(&quot;#progress&quot;).css({ width: progress + &quot;%&quot; });<br>                        $(&quot;#label&quot;).html(progress + &quot;%&quot;);<br>                    }<br>                );<br>            },<br>            10<br>        );<br>    }</pre><pre>    function stopUpdatingProgressIndicator() {<br>        clearInterval(intervalId);<br>    }</pre><pre>&lt;/script&gt;</pre><p>3. Edit file views <em>HomeController.cs</em> in <em>Controller Folder</em> like below :</p><pre>using System;<br>using System.Collections.Generic;<br>using System.Diagnostics;<br>using System.Linq;<br>using System.Threading.Tasks;<br>using Microsoft.AspNetCore.Mvc;<br>using upload_file.Models;<br>using Microsoft.AspNetCore.Hosting;<br>using System.IO;<br>using System.Data;<br>using Microsoft.EntityFrameworkCore;<br>using Microsoft.AspNetCore.Http;<br>using System.Net.Http.Headers;</pre><pre>namespace upload_file.Controllers<br>{<br>    public class HomeController : Controller<br>    {<br>        private IHostingEnvironment hostingEnvironment;<br>        public HomeController(IHostingEnvironment hostingEnvironment)<br>        {<br>            this.hostingEnvironment = hostingEnvironment;<br>        }</pre><pre>        public IActionResult Index()<br>        {<br>            return View();<br>        }</pre><pre>        [HttpPost]<br>        public async Task&lt;IActionResult&gt; Upload(IList&lt;IFormFile&gt; files)<br>        {<br>            Startup.Progress = 0;</pre><pre>            long totalBytes = files.Sum(f =&gt; f.Length);<br>            long totalReadBytes = 0;<br>            <br>            foreach (IFormFile source in files)<br>            {<br>                string filename = ContentDispositionHeaderValue.Parse(source.ContentDisposition).FileName.ToString().Trim(&#39;&quot;&#39;);</pre><pre>                filename = this.EnsureCorrectFilename(filename);<br>                byte[] buffer = new byte[16 * 1024];</pre><pre>                string namafileExcell = &quot;&quot;;<br>                string namafilenewExcell = &quot;&quot;;<br>                string extension = &quot;&quot;;</pre><pre>                namafileExcell = source.FileName;<br>                extension = namafileExcell.Substring(namafileExcell.LastIndexOf(&#39;.&#39;) + 1);<br>                namafileExcell = namafileExcell.Replace(namafileExcell.Substring(namafileExcell.LastIndexOf(&#39;.&#39;) + 1), &quot;&quot;);<br>                namafilenewExcell = namafileExcell.Replace(&quot;.&quot;, &quot;&quot;) + &quot;_&quot; + DateTime.Now.ToString(&quot;yyyyMMdd_HHmmss&quot;) + &quot;.&quot; + extension;</pre><pre>                var path = Path.Combine(<br>                Directory.GetCurrentDirectory(), &quot;wwwroot\\UploadFile&quot;,<br>                namafilenewExcell);</pre><pre>                if (System.IO.File.Exists(path))<br>                {<br>                    FileInfo f2 = new FileInfo(path);<br>                    f2.Delete();<br>                }</pre><pre>                using (var stream = new FileStream(path, FileMode.Create))<br>                {<br>                    await source.CopyToAsync(stream);<br>                }<br>                <br>                try<br>                {<br>                    int readBytes;<br>                    using (FileStream output = System.IO.File.Create(this.GetPathAndFilename(namafilenewExcell)))<br>                    {<br>                        using (Stream input = source.OpenReadStream())<br>                        {<br>                            while ((readBytes = input.Read(buffer, 0, buffer.Length)) &gt; 0)<br>                            {<br>                                await output.WriteAsync(buffer, 0, readBytes);<br>                                totalReadBytes += readBytes;<br>                                Startup.Progress = (int)((float)totalReadBytes / (float)totalBytes * 100.0);<br>                                await Task.Delay(10); // It is only to make the process slower<br>                            }<br>                        }<br>                    }<br>                }<br>                catch (Exception err)<br>                {<br>                    string msgError = &quot;&quot;;<br>                    msgError = err.ToString();<br>                    Startup.Progress = (int)((float)totalReadBytes / (float)totalBytes * 100.0);<br>                    return Json(new { message = msgError });<br>                }<br></pre><pre>            }<br>            <br>            return Json(new { message = &quot;Data Uploaded Successfully!&quot; });<br>        }</pre><pre>        [HttpPost]<br>        public ActionResult Progress()<br>        {<br>            return this.Content(Startup.Progress.ToString());<br>        }</pre><pre>        private string EnsureCorrectFilename(string filename)<br>        {<br>            if (filename.Contains(&quot;\\&quot;))<br>                filename = filename.Substring(filename.LastIndexOf(&quot;\\&quot;) + 1);</pre><pre>            return filename;<br>        }</pre><pre>        private string GetPathAndFilename(string filename)<br>        {<br>            string path = this.hostingEnvironment.WebRootPath + &quot;\\FileUpload\\&quot;;</pre><pre>            if (!Directory.Exists(path))<br>                Directory.CreateDirectory(path);</pre><pre>            return path + filename;<br>        }<br>    }<br>}</pre><p>4. Later, Modify file <em>Startup.cs </em>like below :</p><pre>using System;<br>using System.Collections.Generic;<br>using System.Linq;<br>using System.Threading.Tasks;<br>using Microsoft.AspNetCore.Builder;<br>using Microsoft.AspNetCore.Hosting;<br>using Microsoft.Extensions.Configuration;<br>using Microsoft.Extensions.DependencyInjection;</pre><pre>namespace upload_file<br>{<br>    public class Startup<br>    {<br>        public static int Progress { get; set; }</pre><pre>        public Startup(IConfiguration configuration, IHostingEnvironment env)<br>        {<br>            Configuration = configuration;<br>            WebRootPath = env.WebRootPath;<br>        }<br>        public static string WebRootPath { get; private set; }<br>        public IConfiguration Configuration { get; }</pre><pre>        // This method gets called by the runtime. Use this method to add services to the container.<br>        public void ConfigureServices(IServiceCollection services)<br>        {<br>            services.AddMvc();<br>        }</pre><pre>        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.<br>        public void Configure(IApplicationBuilder app, IHostingEnvironment env)<br>        {<br>            if (env.IsDevelopment())<br>            {<br>                app.UseDeveloperExceptionPage();<br>                app.UseBrowserLink();<br>            }<br>            else<br>            {<br>                app.UseExceptionHandler(&quot;/Home/Error&quot;);<br>            }</pre><pre>            app.UseStaticFiles();</pre><pre>            app.UseMvc(routes =&gt;<br>            {<br>                routes.MapRoute(<br>                    name: &quot;default&quot;,<br>                    template: &quot;{controller=Home}/{action=Index}/{id?}&quot;);<br>            });<br>        }<br>    }<br>}</pre><p>5. Next Step,Running the application with IIS Express In <strong>Microsoft visual studio 2017</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XqbkGHvkpHGcyFW0QXU_Iw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tARHtr2Z_eOqY37x5H0XTQ.png" /></figure><p>You file has been uploaded in directory <em>\wwwroot\FileUpload.</em></p><p>You can see <strong>ASP .Net Core Upload File With Progress Bar Github</strong> in <a href="https://github.com/eccosuprastyo/asp.net-core/tree/master/upload_file">Here</a>.</p><p>Thank you for reading this article about <strong>ASP .Net Core Upload File With Progress Bar</strong>, I hope this article is useful for you. Visit My Github about ASP.Net Core in <a href="https://github.com/eccosuprastyo/asp.net-core">Here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4c10247e779" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Show Image From Camera Gallery]]></title>
            <link>https://medium.com/@ekosuprastyo15/flutter-show-image-from-camera-gallery-d7d751a093da?source=rss-ddb5d4023977------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7d751a093da</guid>
            <category><![CDATA[flutter-capture-image]]></category>
            <category><![CDATA[flutter-show-image]]></category>
            <category><![CDATA[flutter-gallery-image]]></category>
            <category><![CDATA[flutter-camera-picture]]></category>
            <category><![CDATA[flutter-camera-gallery]]></category>
            <dc:creator><![CDATA[Ecco Suprastyo]]></dc:creator>
            <pubDate>Thu, 21 Nov 2019 04:02:33 GMT</pubDate>
            <atom:updated>2025-10-31T06:56:53.557Z</atom:updated>
            <content:encoded><![CDATA[<p>The Example will show about <strong>Flutter Show Image From Camera Gallery.</strong> This article will creating a simple application using <strong>image_picker Package</strong>. You can read other article with flutter in this section :</p><ul><li><a href="http://camellabs.com/flutter-sqlite-crud-example-form/"><strong>Flutter Sqlite Crud Example Form</strong></a></li><li><a href="http://camellabs.com/how-to-create-listview-in-flutter-dynamic/">How To Create Listview in Flutter Dynamic</a></li></ul><p>First, we must create a project using Visual Studio Code software with name “image_show”. Let’s to create a new project using Visual Studio Code:</p><ol><li>Invoke <strong>View &gt; Command Palette</strong>.</li><li>Type “flutter”, and select the <strong>Flutter: New Project</strong>.</li><li>Enter a project name, example such as “image_show”, and press <strong>Enter</strong>.</li><li>Create or select the parent directory for the new project folder.</li><li>Wait for project creation progress to complete and the main.dart file to appear.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*VXDfvwY9u-04vtyyju8pzw.png" /></figure><p>Next, add the <a href="https://pub.dev/packages/image_picker">image_picker</a> package to your project. The image_picker plugin for iOS and Android for picking images from the image library, and taking new pictures with the camera.</p><pre>dependencies: <br>image_picker: &lt;latest_version&gt;</pre><p>Then we click the get package, wait until the process is complete.</p><p>After we created <strong>pubspec.yaml</strong> , You must edit file with name <strong>main.dart </strong>like below :</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:image_picker/image_picker.dart&#39;;<br>import &#39;dart:io&#39;;</pre><pre>void main() =&gt; runApp(MaterialApp(<br>      home: CameraConnect(),<br>      debugShowCheckedModeBanner: false,<br>    ));</pre><pre>class CameraConnect extends StatefulWidget {<br>  @override<br>  _CameraConnectState createState() =&gt; _CameraConnectState();<br>}</pre><pre>class _CameraConnectState extends State&lt;CameraConnect&gt; {<br>  File image;</pre><pre>  //connect camera<br>  cameraConnect() async {<br>    print(&#39;Picker is Called&#39;);<br>    File img = await ImagePicker.pickImage(source: ImageSource.camera);<br>    if (img != null) {<br>      image = img;<br>      setState(() {});<br>    }<br>  }</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(&#39;Camera Connect&#39;),<br>        backgroundColor: Colors.green,<br>      ),<br>      body: Center(<br>        child: Container(<br>          child: image == null ? Text(&#39;No Image Showing&#39;) : Image.file(image),<br>        ),<br>      ),<br>      floatingActionButton: FloatingActionButton(<br>        backgroundColor: Colors.green,<br>        child: Icon(Icons.add_a_photo),<br>        onPressed: cameraConnect,<br>      ),<br>    );<br>  }<br>}</pre><p>So that the application runs on iOS users then add the following script to the ios / Runner / info.plist folder</p><pre>&lt;key&gt;NSPhotoLibraryUsageDescription&lt;/key&gt;<br>&lt;key&gt;NSCameraUsageDescription&lt;/key&gt;<br>&lt;key&gt;NSMicrophoneUsageDescription&lt;/key&gt;</pre><p>Then because we delete all the scripts in main.dart we need to change the script rules in widget_test.dart to be like this:</p><pre>// This is a basic Flutter widget test.<br>//<br>// To perform an interaction with a widget in your test, use the WidgetTester<br>// utility that Flutter provides. For example, you can send tap and scroll<br>// gestures. You can also use WidgetTester to find child widgets in the widget<br>// tree, read text, and verify that the values of widget properties are correct.</pre><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_test/flutter_test.dart&#39;;</pre><pre>import &#39;package:image_show/main.dart&#39;;</pre><pre>void main() {<br>  testWidgets(&#39;Counter increments smoke test&#39;, (WidgetTester tester) async {<br>    // Build our app and trigger a frame.<br>    await tester.pumpWidget(CameraConnect());</pre><pre>    // Verify that our counter starts at 0.<br>    expect(find.text(&#39;0&#39;), findsOneWidget);<br>    expect(find.text(&#39;1&#39;), findsNothing);</pre><pre>    // Tap the &#39;+&#39; icon and trigger a frame.<br>    await tester.tap(find.byIcon(Icons.add));<br>    await tester.pump();</pre><pre>    // Verify that our counter has incremented.<br>    expect(find.text(&#39;0&#39;), findsNothing);<br>    expect(find.text(&#39;1&#39;), findsOneWidget);<br>  });<br>}</pre><p>The application can be run to show output below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*spf7lKxz566W19-mHgVZzQ.png" /></figure><p>For complete source code you can see in <a href="https://github.com/eccosuprastyo/flutter/tree/master/image_show">Here</a>.</p><p>Thank you for reading this article about <strong>Flutter Show Image From Camera Gallery</strong>, I hope this article is useful for you. Visit My Github about Flutter in <a href="https://github.com/eccosuprastyo/flutter">Here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7d751a093da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Json Array Parse Of Objects]]></title>
            <link>https://medium.com/@ekosuprastyo15/flutter-json-array-parse-of-objects-dbf36a7aa08d?source=rss-ddb5d4023977------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbf36a7aa08d</guid>
            <category><![CDATA[flutter-json-array]]></category>
            <category><![CDATA[flutter-json-object]]></category>
            <category><![CDATA[flutter-parse-json]]></category>
            <category><![CDATA[json-encode-decode]]></category>
            <category><![CDATA[flutter-json-serialize]]></category>
            <dc:creator><![CDATA[Ecco Suprastyo]]></dc:creator>
            <pubDate>Tue, 29 Oct 2019 06:22:34 GMT</pubDate>
            <atom:updated>2025-10-31T06:57:04.385Z</atom:updated>
            <content:encoded><![CDATA[<p>The Example will show about <strong>Flutter Json Array Parse Of Objects.</strong> This article will creating a simple application using <strong>http Package</strong>. You can read other article with flutter in this section :</p><ul><li><a href="http://camellabs.com/flutter-sqlite-crud-example-form/"><strong>Flutter Sqlite Crud Example Form</strong></a></li><li><a href="http://camellabs.com/how-to-create-listview-in-flutter-dynamic/">How To Create Listview in Flutter Dynamic</a></li></ul><p>First, we must create a project using Visual Studio Code software with name “parse_json”. Let’s to create a new project using Visual Studio Code:</p><ol><li>Invoke <strong>View &gt; Command Palette</strong>.</li><li>Type “flutter”, and select the <strong>Flutter: New Project</strong>.</li><li>Enter a project name, example such as “parse_json”, and press <strong>Enter</strong>.</li><li>Create or select the parent directory for the new project folder.</li><li>Wait for project creation progress to complete and the main.dart file to appear.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*VXDfvwY9u-04vtyyju8pzw.png" /></figure><p>Next, add the <a href="https://pub.dev/packages/http">http</a> package to your project. The http package makes it easier to perform network requests, such as fetching data from a JSON endpoint.</p><pre>dependencies:<br>  http: &lt;latest_version&gt;</pre><p>in this example, fetch a JSON large document that contains a list of users objects from the <a href="https://jsonplaceholder.typicode.com/">JSONPlaceholder REST API</a>, using the <a href="https://pub.dev/documentation/http/latest/http/get.html">http.get()</a> method.</p><pre>Future&lt;Null&gt; getData() async{<br>    setState(() {<br>      loading = true;<br>    });<br>    <br>    final responseData = await http.get(&quot;https://jsonplaceholder.typicode.com/users&quot;);</pre><pre>    if(responseData.statusCode == 200){<br>      final data = jsonDecode(responseData.body);<br>      print(data);<br>      setState(() {<br>        for(Map i in data){<br>          listModel.add(User.fromJson(i));<br>        }<br>        loading = false;<br>      });<br>    }<br>  }</pre><p>Later, create a Users class that contains data about a photo. Include a fromJson() factory method to make it easy to create a Users starting with a JSON object.</p><pre>import &#39;dart:convert&#39;;</pre><pre>List&lt;User&gt; modelUserFromJson(String str) =&gt; List&lt;User&gt;.from(json.decode(str).map((x) =&gt; User.fromJson(x)));</pre><pre>String modelUserToJson(List&lt;User&gt; data) =&gt; json.encode(List&lt;dynamic&gt;.from(data.map((x) =&gt; x.toJson())));</pre><pre>class User {<br>  int id;<br>  String name;<br>  String username;<br>  String email;<br>  Address address;<br>  String phone;<br>  String website;<br>  Company company;</pre><pre>  User({<br>    this.id,<br>    this.name,<br>    this.username,<br>    this.email,<br>    this.address,<br>    this.phone,<br>    this.website,<br>    this.company,<br>  });</pre><pre>  factory User.fromJson(Map&lt;String, dynamic&gt; json) =&gt; User(<br>    id: json[&quot;id&quot;],<br>    name: json[&quot;name&quot;],<br>    username: json[&quot;username&quot;],<br>    email: json[&quot;email&quot;],<br>    address: Address.fromJson(json[&quot;address&quot;]),<br>    phone: json[&quot;phone&quot;],<br>    website: json[&quot;website&quot;],<br>    company: Company.fromJson(json[&quot;company&quot;]),<br>  );</pre><pre>  Map&lt;String, dynamic&gt; toJson() =&gt; {<br>    &quot;id&quot;: id,<br>    &quot;name&quot;: name,<br>    &quot;username&quot;: username,<br>    &quot;email&quot;: email,<br>    &quot;address&quot;: address.toJson(),<br>    &quot;phone&quot;: phone,<br>    &quot;website&quot;: website,<br>    &quot;company&quot;: company.toJson(),<br>  };<br>}</pre><pre>class Address {<br>  String street;<br>  String suite;<br>  String city;<br>  String zipcode;<br>  Geo geo;</pre><pre>  Address({<br>    this.street,<br>    this.suite,<br>    this.city,<br>    this.zipcode,<br>    this.geo,<br>  });</pre><pre>  factory Address.fromJson(Map&lt;String, dynamic&gt; json) =&gt; Address(<br>    street: json[&quot;street&quot;],<br>    suite: json[&quot;suite&quot;],<br>    city: json[&quot;city&quot;],<br>    zipcode: json[&quot;zipcode&quot;],<br>    geo: Geo.fromJson(json[&quot;geo&quot;]),<br>  );</pre><pre>  Map&lt;String, dynamic&gt; toJson() =&gt; {<br>    &quot;street&quot;: street,<br>    &quot;suite&quot;: suite,<br>    &quot;city&quot;: city,<br>    &quot;zipcode&quot;: zipcode,<br>    &quot;geo&quot;: geo.toJson(),<br>  };<br>}</pre><pre>class Geo {<br>  String lat;<br>  String lng;</pre><pre>  Geo({<br>    this.lat,<br>    this.lng,<br>  });</pre><pre>  factory Geo.fromJson(Map&lt;String, dynamic&gt; json) =&gt; Geo(<br>    lat: json[&quot;lat&quot;],<br>    lng: json[&quot;lng&quot;],<br>  );</pre><pre>  Map&lt;String, dynamic&gt; toJson() =&gt; {<br>    &quot;lat&quot;: lat,<br>    &quot;lng&quot;: lng,<br>  };<br>}</pre><pre>class Company {<br>  String name;<br>  String catchPhrase;<br>  String bs;</pre><pre>  Company({<br>    this.name,<br>    this.catchPhrase,<br>    this.bs,<br>  });</pre><pre>  factory Company.fromJson(Map&lt;String, dynamic&gt; json) =&gt; Company(<br>    name: json[&quot;name&quot;],<br>    catchPhrase: json[&quot;catchPhrase&quot;],<br>    bs: json[&quot;bs&quot;],<br>  );</pre><pre>  Map&lt;String, dynamic&gt; toJson() =&gt; {<br>    &quot;name&quot;: name,<br>    &quot;catchPhrase&quot;: catchPhrase,<br>    &quot;bs&quot;: bs,<br>  };<br>}</pre><p>You must create file with name <strong>main.dart </strong>like below :</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:parse_json/screens/HomePage.dart&#39;;</pre><pre>void main() =&gt; runApp(MyApp());</pre><pre>class MyApp extends StatelessWidget {<br>  // This widget is the root of your application.<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Flutter Demo&#39;,<br>      theme: ThemeData(</pre><pre>        primarySwatch: Colors.blue,<br>      ),<br>      home: PageHome(),debugShowCheckedModeBanner: false,<br>    );<br>  }<br>}</pre><pre>class PageHome extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(&#39;Retrieve JSON Flutter&#39;),<br>      ),</pre><pre>      body: Center(<br>        child: Column(<br>          children: &lt;Widget&gt;[</pre><pre>            MaterialButton(<br>              onPressed: () {<br>                Navigator.push(context, MaterialPageRoute(builder: (context) =&gt; HomePage()));<br>              },<br>              child: Text(&#39;Get List JSON User&#39;),<br>              color: Colors.blue,<br>              textColor: Colors.white,<br>            ),<br>          ],<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>We need to create main screen to first launch application with name <strong><em>HomePage.dart</em></strong> as below:</p><pre>import &#39;dart:convert&#39;;</pre><pre>import &#39;package:parse_json/models/user.dart&#39;;<br>import &#39;package:parse_json/screens/HomePageDetail.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:http/http.dart&#39; as http;<br>import &#39;dart:async&#39;;<br>import &#39;dart:convert&#39;;</pre><pre>class HomePage extends StatefulWidget {<br>  @override<br>  _HomePageState createState() =&gt; _HomePageState();<br>}</pre><pre>class _HomePageState extends State&lt;HomePage&gt; {<br>  // Membuat List Dari data Internet<br>  List&lt;User&gt; listModel = [];<br>  var loading = false;<br>  <br>  Future&lt;Null&gt; getData() async{<br>    setState(() {<br>      loading = true;<br>    });<br>    <br>    final responseData = await http.get(&quot;https://jsonplaceholder.typicode.com/users&quot;);</pre><pre>    if(responseData.statusCode == 200){<br>      final data = jsonDecode(responseData.body);<br>      print(data);<br>      setState(() {<br>        for(Map i in data){<br>          listModel.add(User.fromJson(i));<br>        }<br>        loading = false;<br>      });<br>    }<br>  }</pre><pre>  //Panggil Data / Call Data<br>  @override<br>  void initState() {<br>    // TODO: implement initState<br>    super.initState();<br>    getData();<br>  }<br></pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar:  AppBar(<br>        title: Text(&#39;Home Page List User&#39;),<br>        centerTitle: true,<br>      ),</pre><pre>      body: Container(<br>        child: loading ? Center (child: CircularProgressIndicator()) : ListView.builder(<br>          itemCount: listModel.length,<br>            itemBuilder: (context, i){<br>              final nDataList = listModel[i];<br>              return Container(<br>                child: InkWell(<br>                  onTap: (){<br>                    Navigator.push(context, MaterialPageRoute(builder: (context) =&gt; HomePageDetail(<br>                      dName: nDataList.name,<br>                      dEmail: nDataList.email,<br>                      dPhone: nDataList.phone,<br>                      dCity: nDataList.address.city,<br>                      dZip: nDataList.address.zipcode,<br>                    )));<br>                  },<br>                  child: Card(<br>                    color: Colors.amber[100],<br>                    margin: EdgeInsets.all(15),<br>                    child: Padding(<br>                      padding: EdgeInsets.all(16),<br>                      child: Column(<br>                        crossAxisAlignment: CrossAxisAlignment.start,<br>                        children: &lt;Widget&gt;[<br>                          Text(nDataList.name, style: TextStyle(<br>                              fontWeight: FontWeight.bold,<br>                              fontSize: 18,<br>                              color: Colors.green),<br>                          ),<br>                          Text(nDataList.email),<br>                          Text(nDataList.phone),<br>                          Text(nDataList.website),</pre><pre>                          SizedBox(height: 10,),<br>                          Text(&quot;Address&quot;, style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),),<br>                          Text(nDataList.address.street),<br>                          Text(nDataList.address.city),<br>                          Text(nDataList.address.suite),<br>                          Text(nDataList.address.zipcode),</pre><pre>                          SizedBox(height: 10,),<br>                          Text(&quot;Company&quot;, style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),),<br>                          Text(nDataList.company.name),<br>                        ],<br>                      ),<br>                    ),<br>                  ),<br>                ),<br>              );<br>            }<br>        ),<br>      ),</pre><pre>    );<br>  }<br>}</pre><p>And we need to second screen to show the result with name <strong><em>HomePageDetail.dart</em></strong> as below :</p><pre>import &#39;package:flutter/material.dart&#39;;</pre><pre>class HomePageDetail extends StatefulWidget {<br>  String dName, dEmail, dPhone, dCity, dZip;</pre><pre>  HomePageDetail({this.dName, this.dEmail, this.dPhone, this.dCity, this.dZip});</pre><pre>  @override<br>  _HomePageDetailState createState() =&gt; _HomePageDetailState();<br>}</pre><pre>class _HomePageDetailState extends State&lt;HomePageDetail&gt; {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(&#39;Detail User&#39;),<br>        backgroundColor: Colors.blue,<br>      ),<br>      body: ListView(<br>        children: &lt;Widget&gt;[<br>          Container(<br>            padding: EdgeInsets.all(16),<br>            child: Card(<br>              child: Padding(<br>                padding: EdgeInsets.all(8),<br>                child: Column(<br>                  mainAxisAlignment: MainAxisAlignment.start,<br>                  children: &lt;Widget&gt;[<br>                    Container(<br>                      child: Text(<br>                        &#39;With One Class&#39;,<br>                        style: TextStyle(<br>                            fontSize: 20, fontWeight: FontWeight.bold),<br>                      ),<br>                    ),<br>                    Container(<br>                      child: Column(<br>                        children: &lt;Widget&gt;[<br>                          Text(<br>                            &quot;${widget.dName}&quot;,<br>                            style: TextStyle(<br>                                fontSize: 24,<br>                                color: Colors.green,<br>                                fontWeight: FontWeight.bold),<br>                          ),<br>                          Text(<br>                            &quot;Email : ${widget.dEmail}&quot;,<br>                            style: TextStyle(fontSize: 16),<br>                          ),<br>                          Text(<br>                            &quot;Phone : ${widget.dPhone}&quot;,<br>                            style: TextStyle(fontSize: 16),<br>                          ),<br>                          Text(<br>                            &quot;City : ${widget.dCity}&quot;,<br>                            style: TextStyle(fontSize: 16),<br>                          ),<br>                          Text(<br>                            &quot;Zip Postal : ${widget.dZip}&quot;,<br>                            style: TextStyle(fontSize: 16),<br>                          ),<br>                        ],<br>                      ),<br>                    )<br>                  ],<br>                ),<br>              ),<br>            ),<br>          ),<br>          SizedBox(<br>            height: 40,<br>          ),<br>          Container(<br>            child: Column(<br>              children: &lt;Widget&gt;[<br>                new NameDetail(<br>                  name: widget.dName,<br>                  email: widget.dEmail,<br>                ),<br>                new BagianIcon(),<br>                new BagianContact(<br>                  phone: widget.dPhone,<br>                  city: widget.dCity,<br>                  postal: widget.dZip,<br>                )<br>              ],<br>            ),<br>          ),<br>        ],<br>      ),<br>    );<br>  }<br>}</pre><pre>class NameDetail extends StatelessWidget {<br>  final String name, email;<br>  NameDetail({this.name, this.email});<br>  @override<br>  Widget build(BuildContext context) {<br>    // TODO: implement build<br>    return Container(<br>      padding: EdgeInsets.all(16),<br>      child: Row(<br>        children: &lt;Widget&gt;[<br>          Expanded(<br>            child: Column(<br>              crossAxisAlignment: CrossAxisAlignment.start,<br>              children: &lt;Widget&gt;[<br>                Text(<br>                  name,<br>                  style: TextStyle(<br>                      fontWeight: FontWeight.bold,<br>                      color: Colors.green,<br>                      fontSize: 24),<br>                ),<br>                Text(<br>                  &quot;Email : $email&quot;,<br>                  style: TextStyle(fontSize: 16),<br>                ),<br>              ],<br>            ),<br>          ),<br>          Row(<br>            children: &lt;Widget&gt;[<br>              Icon(<br>                Icons.star,<br>                size: 40,<br>                color: Colors.orange,<br>              ),<br>              Text(<br>                &quot;12&quot;,<br>                style: TextStyle(fontSize: 12),<br>              )<br>            ],<br>          )<br>        ],<br>      ),<br>    );<br>  }<br>}</pre><pre>class BagianIcon extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Container(<br>      padding: EdgeInsets.all(10),<br>      child: Row(<br>        children: &lt;Widget&gt;[<br>          IconText(iconData: Icons.camera, text: &quot;Camera&quot;,),</pre><pre>          IconText(iconData: Icons.phone, text: &quot;Phone&quot;,),</pre><pre>          IconText(iconData: Icons.message, text: &quot;Message&quot;,),<br>        ],<br>      ),<br>    );<br>  }<br>}</pre><pre>class IconText extends StatelessWidget {<br>  IconText({this.iconData, this.text});<br>  final IconData iconData;<br>  final String text;<br>  @override<br>  Widget build(BuildContext context) {<br>    // TODO: implement build<br>    return Expanded(<br>      child: Column(<br>        children: &lt;Widget&gt;[<br>          Icon(<br>            iconData,<br>            size: 20,<br>            color: Colors.green,<br>          ),<br>          Text(<br>            text,<br>            style: TextStyle(fontSize: 12, color: Colors.green),<br>          ),<br>        ],<br>      ),<br>    );<br>  }<br>}</pre><pre>class BagianContact extends StatelessWidget {<br>  String phone, city, postal;</pre><pre>  BagianContact({this.phone, this.city, this.postal});</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    // TODO: implement build<br>    return Container(<br>      padding: EdgeInsets.all(16),<br>      child: Card(<br>        child: Padding(<br>          padding: EdgeInsets.all(16),<br>          child: Column(<br>            children: &lt;Widget&gt;[<br>              Container(<br>                child: Text(<br>                  &#39;With many Class&#39;,<br>                  style: TextStyle(fontSize: 16),<br>                ),<br>              ),<br>              Container(<br>                child: Text(<br>                  phone,<br>                  style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),<br>                ),<br>              ),<br>              Container(<br>                child: Text(<br>                  city,<br>                  style: TextStyle(fontSize: 16),<br>                ),<br>              ),<br>              Container(<br>                child: Text(<br>                  postal,<br>                  style: TextStyle(fontSize: 16),<br>                ),<br>              ),<br>            ],<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>The application can be run to show output below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*palTYXMlRe1lm1mKzLutng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*p14UWg8P2XstgZpYcLgo2Q.png" /></figure><p>For complete source code you can see in <a href="https://github.com/eccosuprastyo/flutter/tree/master/parse_json">Here</a>.</p><p>Thank you for reading this article about <strong>Flutter Json Array Parse Of Objects</strong>, I hope this article is useful for you. Visit My Github about Flutter in <a href="https://github.com/eccosuprastyo/flutter">Here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbf36a7aa08d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Sqlite Crud Example Form]]></title>
            <link>https://medium.com/@ekosuprastyo15/flutter-sqlite-crud-example-form-35aff82f386d?source=rss-ddb5d4023977------2</link>
            <guid isPermaLink="false">https://medium.com/p/35aff82f386d</guid>
            <category><![CDATA[flutter-crud-form]]></category>
            <category><![CDATA[flutter-crud-operation]]></category>
            <category><![CDATA[crud-sqlite-flutter]]></category>
            <category><![CDATA[flutter-crud-database]]></category>
            <category><![CDATA[flutter-crud-example]]></category>
            <dc:creator><![CDATA[Ecco Suprastyo]]></dc:creator>
            <pubDate>Wed, 16 Oct 2019 04:11:35 GMT</pubDate>
            <atom:updated>2025-10-31T06:58:14.547Z</atom:updated>
            <content:encoded><![CDATA[<p>The Example will show about <strong>Flutter Sqlite Crud Example Form.</strong> This article will creating a simple application using <strong>SQLite database</strong>. You can read other article with flutter in this section :</p><ul><li><a href="http://camellabs.com/flutter-login-with-database-sqlite/">Flutter Login With Database SQLite</a></li><li><a href="http://camellabs.com/how-to-create-listview-in-flutter-dynamic/">How To Create Listview in Flutter Dynamic</a></li></ul><p>First, we must create a project using Visual Studio Code software with name “simple_form_crud”. Let’s to create a new project using Visual Studio Code:</p><ol><li>Invoke <strong>View &gt; Command Palette</strong>.</li><li>Type “flutter”, and select the <strong>Flutter: New Project</strong>.</li><li>Enter a project name, example such as “simple_form_crud”, and press <strong>Enter</strong>.</li><li>Create or select the parent directory for the new project folder.</li><li>Wait for project creation progress to complete and the main.dart file to appear.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*VXDfvwY9u-04vtyyju8pzw.png" /></figure><p>After that, create the database file in the directory application that was created. (e.g [<em>projectname</em>]/data/[<em>databasename</em>].db.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*1ChVFr5bFq2VbeJZe62BBA.png" /></figure><p>we must prepare the file database using sqlite first. All we have to do is create a file with the .db extension first.</p><p>This example using webview flutter plugin sqflite: any<em>. </em>Edit file <strong><em>pubspec.yaml</em></strong> in your directory should look something like and then update flutter package.</p><pre>name: simple_form_crud<br>description: A new Flutter project.</pre><pre># The following defines the version and build number for your application.<br># A version number is three numbers separated by dots, like 1.2.43<br># followed by an optional build number separated by a +.<br># Both the version and the builder number may be overridden in flutter<br># build by specifying --build-name and --build-number, respectively.<br># In Android, build-name is used as versionName while build-number used as versionCode.<br># Read more about Android versioning at <a href="https://developer.android.com/studio/publish/versioning">https://developer.android.com/studio/publish/versioning</a><br># In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.<br># Read more about iOS versioning at<br># <a href="https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html">https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html</a><br>version: 1.0.0+1</pre><pre>environment:<br>  sdk: &quot;&gt;=2.1.0 &lt;3.0.0&quot;</pre><pre>dependencies:<br>  flutter:<br>    sdk: flutter</pre><pre>  # The following adds the Cupertino Icons font to your application.<br>  # Use with the CupertinoIcons class for iOS style icons.<br>  cupertino_icons: ^0.1.2<br>  sqflite: any<br>  path_provider: ^0.4.0</pre><pre>dev_dependencies:<br>  flutter_test:<br>    sdk: flutter<br></pre><pre># For information on the generic Dart part of this file, see the<br># following page: <a href="https://www.dartlang.org/tools/pub/pubspec">https://www.dartlang.org/tools/pub/pubspec</a></pre><pre># The following section is specific to Flutter.<br>flutter:</pre><pre>  # The following line ensures that the Material Icons font is<br>  # included with your application, so that you can use the icons in<br>  # the material Icons class.<br>  uses-material-design: true</pre><pre>  assets:<br>    - data/flutter.db<br>  # To add assets to your application, add an assets section, like this:<br>  # assets:<br>  #  - images/a_dot_burr.jpeg<br>  #  - images/a_dot_ham.jpeg</pre><pre>  # An image asset can refer to one or more resolution-specific &quot;variants&quot;, see<br>  # <a href="https://flutter.dev/assets-and-images/#resolution-aware.">https://flutter.dev/assets-and-images/#resolution-aware.</a></pre><pre>  # For details regarding adding assets from package dependencies, see<br>  # <a href="https://flutter.dev/assets-and-images/#from-packages">https://flutter.dev/assets-and-images/#from-packages</a></pre><pre>  # To add custom fonts to your application, add a fonts section here,<br>  # in this &quot;flutter&quot; section. Each entry in this list should have a<br>  # &quot;family&quot; key with the font family name, and a &quot;fonts&quot; key with a<br>  # list giving the asset and other descriptors for the font. For<br>  # example:<br>  # fonts:<br>  #   - family: Schyler<br>  #     fonts:<br>  #       - asset: fonts/Schyler-Regular.ttf<br>  #       - asset: fonts/Schyler-Italic.ttf<br>  #         style: italic<br>  #   - family: Trajan Pro<br>  #     fonts:<br>  #       - asset: fonts/TrajanPro.ttf<br>  #       - asset: fonts/TrajanPro_Bold.ttf<br>  #         weight: 700<br>  #<br>  # For details regarding fonts from package dependencies,<br>  # see <a href="https://flutter.dev/custom-fonts/#from-packages">https://flutter.dev/custom-fonts/#from-packages</a></pre><p>For the structure folders you can see in below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*J-irPCleW5yovq-gXQncmQ.png" /></figure><p>Next step,We’re going to need to create <strong>entity class</strong> with name <strong><em>user.dart</em></strong> in directory [projectname]/lib/models/[classname] us manage a user’s data.</p><pre>class User {<br>  int _id;<br>  String _username;<br>  String _password;</pre><pre>  User(this._username, this._password);</pre><pre>  User.fromMap(dynamic obj) {<br>    this._id = obj[&#39;id&#39;];<br>    this._username = obj[&#39;username&#39;];<br>    this._password = obj[&#39;password&#39;];<br>  }</pre><pre>  String get username =&gt; _username;<br>  String get password =&gt; _password;<br>  int get id =&gt; _id;</pre><pre>  Map&lt;String, dynamic&gt; toMap() {<br>    var map = new Map&lt;String, dynamic&gt;();<br>    map[&quot;id&quot;] = _id;<br>    map[&quot;username&quot;] = _username;<br>    map[&quot;password&quot;] = _password;<br>    return map;<br>  }<br>}</pre><p>And Create database helper class with <strong><em>database_helper.dart</em></strong> like that :</p><pre>import &#39;dart:io&#39;;<br>import &#39;dart:typed_data&#39;;<br>import &#39;package:flutter/services.dart&#39;;<br>import &#39;package:path/path.dart&#39;;<br>import &#39;dart:async&#39;;<br>import &#39;package:path_provider/path_provider.dart&#39;;<br>import &#39;package:sqflite/sqflite.dart&#39;;</pre><pre>class DatabaseHelper {<br>  static final DatabaseHelper _instance = new DatabaseHelper.internal();<br>  factory DatabaseHelper() =&gt; _instance;</pre><pre>  static Database _db;</pre><pre>  Future&lt;Database&gt; get db async {<br>    if (_db != null) {<br>      return _db;<br>    }<br>    _db = await initDb();<br>    return _db;<br>  }</pre><pre>  DatabaseHelper.internal();</pre><pre>  initDb() async {<br>    <br>    Directory documentDirectory = await getApplicationDocumentsDirectory();<br>    String path = join(documentDirectory.path, &quot;data_flutter.db&quot;);</pre><pre>    // Only copy if the database doesn&#39;t exist<br>    if (FileSystemEntity.typeSync(path) == FileSystemEntityType.notFound){<br>      // Load database from asset and copy<br>      ByteData data = await rootBundle.load(join(&#39;data&#39;, &#39;flutter.db&#39;));<br>      List&lt;int&gt; bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);</pre><pre>      // Save copied asset to documents<br>      await new File(path).writeAsBytes(bytes);<br>    }</pre><pre>    var ourDb = await openDatabase(path);<br>    return ourDb;<br>  }<br>}</pre><p>After we create <strong><em>database_helper.dart</em></strong>, create file for the query to CRUD operation. The file <strong><em>user_ctr.dart</em></strong> like below :</p><pre>import &#39;package:simple_form_crud/models/user.dart&#39;;<br>import &#39;dart:async&#39;;<br>import &#39;package:simple_form_crud/data/database_helper.dart&#39;;</pre><pre>class UserCtr {<br>DatabaseHelper con = new DatabaseHelper();</pre><pre>//insertion<br>  Future&lt;int&gt; saveUser(User user) async {<br>    var dbClient = await con.db;<br>    int res = await dbClient.insert(&quot;User&quot;, user.toMap());<br>    return res;<br>  }</pre><pre>  //deletion<br>  Future&lt;int&gt; deleteUser(int user) async {<br>    var dbClient = await con.db;<br>    int res = await dbClient.rawDelete(&#39;DELETE FROM User WHERE id = ?&#39;, [user]);<br>    return res;<br>  }</pre><pre>  Future&lt;User&gt; checkUser(String user, String password) async {<br>    var dbClient = await con.db;<br>    var res = await dbClient.rawQuery(&quot;SELECT * FROM user WHERE username = &#39;$user&#39; and password = &#39;$password&#39;&quot;);<br>    <br>    if (res.length &gt; 0) {<br>      return new User.fromMap(res.first);<br>    }</pre><pre>    return null;<br>  }</pre><pre>  Future&lt;List&lt;User&gt;&gt; getAllUser() async {<br>    var dbClient = await con.db;<br>    var res = await dbClient.query(&quot;user&quot;);<br>    <br>    List&lt;User&gt; list =<br>        res.isNotEmpty ? res.map((c) =&gt; User.fromMap(c)).toList() : null;</pre><pre>    return list;<br>  }<br>}</pre><p>Later, we create screen form in directory [projectname]/lib/screens/[classname] with name <strong>home_pages.dart</strong></p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:simple_form_crud/models/user.dart&#39;;<br>import &#39;package:simple_form_crud/services/response/user_response.dart&#39;;</pre><pre>class HomePage extends StatefulWidget {<br>  @override<br>  _UserPageState createState() =&gt; new _UserPageState();<br>}</pre><pre>class _UserPageState extends State&lt;HomePage&gt; implements CreateUserCallBack,GetUserCallBack,DeleteUserCallBack {<br>  BuildContext _ctx;<br>  bool _isLoading = false;<br>  final formKey = new GlobalKey&lt;FormState&gt;();<br>  final scaffoldKey = new GlobalKey&lt;ScaffoldState&gt;();</pre><pre>  String _username, _password;</pre><pre>  CreateUserResponse _responseCreate;<br>  GetUserResponse _responseGet;<br>  DeleteUserResponse _responseDelete;<br>  List&lt;User&gt; listUser;</pre><pre>  _UserPageState() {<br>    _responseCreate = new CreateUserResponse(this);<br>    _responseGet = new GetUserResponse(this);<br>    _responseDelete = new DeleteUserResponse(this);<br>    listUser = new List&lt;User&gt;(); <br>    _responseGet.doGet();<br>  }</pre><pre>  void _submit() {<br>    final form = formKey.currentState;</pre><pre>    if (form.validate()) {<br>      setState(() {<br>        _isLoading = true;<br>        form.save();<br>        _responseCreate.doCreate(_username, _password);<br>      });<br>    }<br>  }</pre><pre>  void _delete(int id) {<br>    final form = formKey.currentState;</pre><pre>    if (form.validate()) {<br>      setState(() {<br>        _isLoading = true;<br>        _responseDelete.doDelete(id);<br>      });<br>    }<br>  }</pre><pre>  void _showSnackBar(String text) {<br>    scaffoldKey.currentState.showSnackBar(new SnackBar(<br>      content: new Text(text),<br>    ));<br>  }</pre><pre>    SingleChildScrollView dataBody() {<br>    return SingleChildScrollView(<br>      scrollDirection: Axis.vertical,<br>      child: DataTable(<br>        columns: [<br>          DataColumn(label: Text(&#39;Id&#39;)),<br>          DataColumn(label: Text(&#39;Username&#39;)),<br>          DataColumn(label: Text(&#39;Password&#39;)),<br>          DataColumn(label: Text(&#39;Action&#39;)),<br>        ],<br>        rows:<br>            listUser // Loops through dataColumnText, each iteration assigning the value to element<br>                .map(<br>                  ((element) =&gt; DataRow(<br>                        cells: &lt;DataCell&gt;[<br>                          DataCell(Text(element.id.toString())), //Extracting from Map element the value<br>                          DataCell(Text(element.username)),<br>                          DataCell(Text(element.password)),<br>                          DataCell( new IconButton(<br>                            icon: const Icon(Icons.delete_forever,<br>                                color: const Color(0xFF167F67)),<br>                            onPressed: () =&gt; _delete(element.id),<br>                            alignment: Alignment.centerLeft,<br>                          )),<br>                        ],<br>                      )),<br>                )<br>                .toList(),<br>      ),<br>    );<br>  }</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    _ctx = context;</pre><pre>    var loginBtn = new RaisedButton(<br>      onPressed: _submit,<br>      child: new Text(&quot;Save&quot;),<br>      color: Colors.green,<br>    );<br>    var userForm = new Column(<br>      crossAxisAlignment: CrossAxisAlignment.center,<br>      children: &lt;Widget&gt;[<br>        new Form(<br>          key: formKey,<br>          child: new Column(<br>            children: &lt;Widget&gt;[<br>              new Padding(<br>                padding: const EdgeInsets.all(10.0),<br>                child: new TextFormField(<br>                  onSaved: (val) =&gt; _username = val,<br>                  decoration: new InputDecoration(labelText: &quot;Username&quot;),<br>                ),<br>              ),<br>              new Padding(<br>                padding: const EdgeInsets.all(10.0),<br>                child: new TextFormField(<br>                  onSaved: (val) =&gt; _password = val,<br>                  decoration: new InputDecoration(labelText: &quot;Password&quot;),<br>                ),<br>              )<br>            ],<br>          ),<br>        ),<br>        loginBtn<br>      ],<br>    );</pre><pre>    return new Scaffold(<br>      appBar: new AppBar(<br>        title: new Text(&quot;User Page&quot;),<br>      ),<br>      key: scaffoldKey,<br>      body: new Column(<br>          mainAxisSize: MainAxisSize.min,<br>          mainAxisAlignment: MainAxisAlignment.center,<br>          verticalDirection: VerticalDirection.down,<br>          children: &lt;Widget&gt;[<br>            userForm,<br>            Expanded(<br>              child : dataBody(),<br>            ),<br>          ],<br>        ),<br>    );<br>  }</pre><pre>  @override<br>  void onCreateUserError(String error) {<br>    // TODO: implement onLoginError<br>    _showSnackBar(error);<br>    setState(() {<br>      _isLoading = false;<br>    });<br>  }</pre><pre>  @override<br>  void onCreateUserSuccess(int user) async {    </pre><pre>    if(user &gt; 0){<br>      // TODO: implement onLoginSuccess<br>      _responseGet.doGet();<br>      _showSnackBar(&quot;data has been saved successfully&quot;);<br>      setState(() {<br>        _isLoading = false;<br>      });<br>    }else{<br>      // TODO: implement onLoginSuccess<br>      _showSnackBar(&quot;Failed, please check data&quot;);<br>      setState(() {<br>        _isLoading = false;<br>      });<br>    }<br>    <br>  }</pre><pre> @override<br>  void onGetUserError(String error) {<br>    // TODO: implement onLoginError<br>    _showSnackBar(error);<br>    setState(() {<br>      _isLoading = false;<br>    });<br>  }</pre><pre>   @override<br>  void onGetUserSuccess(List&lt;User&gt; user) async {    </pre><pre>    if(user != null){<br>      // TODO: implement onLoginSuccess<br>      listUser = user;<br>      setState(() {});<br>    }else{<br>    }<br>    <br>  }</pre><pre>  @override<br>  void onDeleteUserError(String error) {<br>    // TODO: implement onLoginError<br>    _showSnackBar(error);<br>    setState(() {<br>      _isLoading = false;<br>    });<br>  }</pre><pre>  @override<br>  void onDeleteUserSuccess(int user) async {    </pre><pre>    if(user &gt; 0){<br>      _responseGet.doGet();<br>      // TODO: implement onLoginSuccess<br>      _showSnackBar(&quot;data has been delete successfully&quot;);<br>      setState(() {<br>        _isLoading = false;<br>      });<br>    }else{<br>      // TODO: implement onLoginSuccess<br>      _showSnackBar(&quot;Failed, please check data&quot;);<br>      setState(() {<br>        _isLoading = false;<br>      });<br>    }<br>    <br>  }<br>}</pre><p>The screen will call the function for the request or response operation. So, you must create request class and response class like below :</p><pre>import &#39;dart:async&#39;;</pre><pre>import &#39;package:simple_form_crud/models/user.dart&#39;;<br>import &#39;package:simple_form_crud/data/query/user_ctr.dart&#39;;</pre><pre>class UserRequest {<br>  UserCtr con = new UserCtr();</pre><pre> Future&lt;int&gt; createUser(User user) {<br>    var result = con.saveUser(user);<br>    return result;<br>  }</pre><pre>  Future&lt;List&lt;User&gt;&gt; getUser() {<br>    var result = con.getAllUser();<br>    return result;<br>  }</pre><pre>  Future&lt;int&gt; deleteUser(int user) {<br>    var result = con.deleteUser(user);<br>    return result;<br>  }<br>}</pre><pre>import &#39;package:simple_form_crud/services/request/user_request.dart&#39;;<br>import &#39;package:simple_form_crud/models/user.dart&#39;;</pre><pre>abstract class CreateUserCallBack {<br>  void onCreateUserSuccess(int user);<br>  void onCreateUserError(String error);<br>}</pre><pre>abstract class GetUserCallBack {<br>  void onGetUserSuccess(List&lt;User&gt; user);<br>  void onGetUserError(String error);<br>}</pre><pre>abstract class DeleteUserCallBack {<br>  void onDeleteUserSuccess(int user);<br>  void onDeleteUserError(String error);<br>}</pre><pre>class CreateUserResponse {<br>  CreateUserCallBack _callBackCreate;<br>  UserRequest userRequest = new UserRequest();<br>  CreateUserResponse(this._callBackCreate);</pre><pre>  doCreate(String username, String password) {<br>    var fido = User(username, password);<br>    <br>    userRequest<br>        .createUser(fido)<br>        .then((user) =&gt; _callBackCreate.onCreateUserSuccess(user))<br>        .catchError((onError) =&gt; _callBackCreate.onCreateUserError(onError.toString()));<br>  } <br>}</pre><pre>class GetUserResponse {<br>  GetUserCallBack _callBackGet;<br>  UserRequest userRequest = new UserRequest();<br>  GetUserResponse(this._callBackGet);</pre><pre>  doGet() {    <br>    userRequest<br>        .getUser()<br>        .then((user) =&gt; _callBackGet.onGetUserSuccess(user))<br>        .catchError((onError) =&gt; _callBackGet.onGetUserError(onError.toString()));<br>  } <br>}</pre><pre>class DeleteUserResponse {<br>  DeleteUserCallBack _callBackDelete;<br>  UserRequest userRequest = new UserRequest();<br>  DeleteUserResponse(this._callBackDelete);</pre><pre>  doDelete(int id) {<br>    <br>    userRequest<br>        .deleteUser(id)<br>        .then((user) =&gt; _callBackDelete.onDeleteUserSuccess(user))<br>        .catchError((onError) =&gt; _callBackDelete.onDeleteUserError(onError.toString()));<br>  } <br>}</pre><p>The last, we create <strong>main.dart</strong> for the root.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:simple_form_crud/screens/home_pages.dart&#39;;</pre><pre>void main() =&gt; runApp(new MyApp());</pre><pre>final routes = {<br>  &#39;/home&#39;: (BuildContext context) =&gt; new HomePage(),<br>  &#39;/&#39;: (BuildContext context) =&gt; new HomePage(),<br>};</pre><pre>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return new MaterialApp(<br>      title: &#39;Sqflite App&#39;,<br>      theme: new ThemeData(primarySwatch: Colors.teal),<br>      routes: routes,<br>    );<br>  }<br>}</pre><p>The application can be run to show output below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*hGyWbEeJws4zaH_Vak4hGg.png" /></figure><p>For complete source code you can see in <a href="https://github.com/eccosuprastyo/flutter/tree/master/simple_form_crud">Here</a>.</p><p>Thank you for reading this article about <strong>Flutter Sqlite Crud Example Form</strong>, I hope this article is useful for you. Visit My Github about Flutter in <a href="https://github.com/eccosuprastyo/flutter">Here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35aff82f386d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gin Gonic Mysql Golang Example]]></title>
            <link>https://medium.com/@ekosuprastyo15/gin-gonic-mysql-golang-example-9185f202e968?source=rss-ddb5d4023977------2</link>
            <guid isPermaLink="false">https://medium.com/p/9185f202e968</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[api-gin-gonic]]></category>
            <category><![CDATA[go-example-project]]></category>
            <category><![CDATA[gin-example-project]]></category>
            <category><![CDATA[gin-gonic]]></category>
            <dc:creator><![CDATA[Ecco Suprastyo]]></dc:creator>
            <pubDate>Tue, 08 Oct 2019 07:35:32 GMT</pubDate>
            <atom:updated>2025-10-31T06:58:19.343Z</atom:updated>
            <content:encoded><![CDATA[<p>This article will discuss about one of from backend famework in Go Language. The framework is Gin Gonic Framework. Gin Gonic is the framework to build API. For more detail, What is the gin gonic framework? Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to <a href="https://github.com/julienschmidt/httprouter">httprouter</a>. If you need performance and good productivity, you will love Gin. For Detail Description you can see here. <a href="https://github.com/gin-gonic/gin"><strong>Gin Gonic</strong></a></p><p>CURD Application need API’s like belows:</p><ol><li>POST todos/</li><li>GET todos/</li><li>GET todos/{id}</li><li>PUT todos/{id}</li><li>DELETE todos/{id}</li></ol><p>This example will use Mysql database for the connection the services. and we will setup connection when starting write code.</p><p>The first need <a href="https://golang.org/">Go</a> installed (<strong>version 1.10+ is required</strong>), then you can use the below Go command to install Gin.</p><pre>$ go get -u github.com/gin-gonic/gin</pre><p>Go to your $GOPATH/src and make a directory <strong>gin-login. </strong>Inside the gin-login directory create 4 folder like this controllers,models,mappings,main. Example structure folder :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/167/1*NgDk_ufFnVuXZJWQl6FuvA.png" /></figure><p>Inside the <em>main</em> directory create a file <strong>main.go</strong>.Import the “gin framework” to our project and create the routes like below inside main function.</p><pre>package main</pre><pre>import (<br>	&quot;goapi/mappings&quot;</pre><pre>	_ &quot;github.com/go-sql-driver/mysql&quot;<br>)</pre><pre>func main() {</pre><pre>	mappings.CreateUrlMappings()<br>	// Listen and server on 0.0.0.0:8080<br>	mappings.Router.Run(&quot;:8080&quot;)</pre><pre>}</pre><p>I like to add a prefix of the api’s like “v1/users/”, that’s why we’ll use the router Group in <em>mappings</em> directory method like below.</p><pre>package mappings</pre><pre>import (<br>	&quot;goapi/controllers&quot;</pre><pre>	&quot;github.com/gin-gonic/gin&quot;<br>)</pre><pre>var Router *gin.Engine</pre><pre>func CreateUrlMappings() {<br>	Router = gin.Default()</pre><pre>	Router.Use(controllers.Cors())<br>	// v1 of the API<br>	v1 := Router.Group(&quot;/v1&quot;)<br>	{<br>		v1.GET(&quot;/users/:id&quot;, controllers.GetUserDetail)<br>		v1.GET(&quot;/users/&quot;, controllers.GetUser)<br>		v1.POST(&quot;/login/&quot;, controllers.Login)<br>		v1.PUT(&quot;/users/:id&quot;, controllers.UpdateUser)<br>		v1.POST(&quot;/users&quot;, controllers.PostUser)<br>	}<br>}</pre><p>We have created five routes and they handle some functions like GetUserDetail, GetUser, , etc.</p><p>Now we need to setup a database connection. To use database pull the gorm package and mysql dialects in our code in folder <em>controllers</em>. Follow the code below:</p><pre>package controllers</pre><pre>import (<br>	&quot;database/sql&quot;<br>	&quot;log&quot;</pre><pre>	&quot;github.com/gin-gonic/gin&quot;<br>	&quot;github.com/go-gorp/gorp&quot;<br>	_ &quot;github.com/go-sql-driver/mysql&quot;<br>)</pre><pre>var dbmap = initDb()</pre><pre>func initDb() *gorp.DbMap {<br>	db, err := sql.Open(&quot;mysql&quot;, &quot;user:password@tcp(localhost:3306)/test&quot;)<br>	checkErr(err, &quot;sql.Open failed&quot;)<br>	dbmap := &amp;gorp.DbMap{Db: db, Dialect: gorp.MySQLDialect{&quot;InnoDB&quot;, &quot;UTF8&quot;}}<br>	err = dbmap.CreateTablesIfNotExists()<br>	checkErr(err, &quot;Create tables failed&quot;)</pre><pre>	return dbmap<br>}</pre><pre>func checkErr(err error, msg string) {<br>	if err != nil {<br>		log.Fatalln(msg, err)<br>	}<br>}</pre><pre>func Cors() gin.HandlerFunc {<br>	return func(c *gin.Context) {<br>		c.Writer.Header().Add(&quot;Access-Control-Allow-Origin&quot;, &quot;*&quot;)<br>		c.Next()<br>	}<br>}</pre><p>In the above code “mysql” is our database driver, “user” is database username, “password” password and “test” is database name. Please change these information as your needs.</p><p>We’ll use the Database function to get the database connection. Lets make a <strong>User</strong> struct in directory <em>Models</em>. The first struct will represent the original User and the second one will hold the transformed user for response to the api. Here we transformed the todo response because we don’t expose some database fields (updated_at, created_at) to the consumer.</p><pre>package models</pre><pre>type User struct {<br>	Id        int64  `db:&quot;ID&quot; json:&quot;id&quot;`<br>	Username  string `db:&quot;Username&quot; json:&quot;username&quot;`<br>	Password  string `db:&quot;Password&quot; json:&quot;password&quot;`<br>	Firstname string `db:&quot;Firstname&quot; json:&quot;firstname&quot;`<br>	Lastname  string `db:&quot;Lastname&quot; json:&quot;lastname&quot;`<br>}</pre><p>User struct has one field extra gin-gonic.Model what does it mean? well, this field will embed a Model struct for us which contains four fields “ID, CreatedAt, UpdatedAt, DeletedAt”.</p><p>Later implement the functions in directory <em>controllers</em> with name login.go</p><pre>package controllers</pre><pre>import (<br>	&quot;log&quot;<br>	&quot;strconv&quot;</pre><pre>	&quot;goapi/models&quot;</pre><pre>	&quot;github.com/gin-gonic/gin&quot;<br>	_ &quot;github.com/go-sql-driver/mysql&quot;<br>)</pre><pre>func GetUser(c *gin.Context) {<br>	var user []models.User<br>	_, err := dbmap.Select(&amp;user, &quot;select * from user&quot;)</pre><pre>	if err == nil {<br>		c.JSON(200, user)<br>	} else {<br>		c.JSON(404, gin.H{&quot;error&quot;: &quot;user not found&quot;})<br>	}</pre><pre>}</pre><pre>func GetUserDetail(c *gin.Context) {<br>	id := c.Params.ByName(&quot;id&quot;)<br>	var user models.User<br>	err := dbmap.SelectOne(&amp;user, &quot;SELECT * FROM user WHERE id=? LIMIT 1&quot;, id)</pre><pre>	if err == nil {<br>		user_id, _ := strconv.ParseInt(id, 0, 64)</pre><pre>		content := &amp;models.User{<br>			Id:        user_id,<br>			Username:  user.Username,<br>			Password:  user.Password,<br>			Firstname: user.Firstname,<br>			Lastname:  user.Lastname,<br>		}<br>		c.JSON(200, content)<br>	} else {<br>		c.JSON(404, gin.H{&quot;error&quot;: &quot;user not found&quot;})<br>	}<br>}</pre><pre>func Login(c *gin.Context) {<br>	var user models.User<br>	c.Bind(&amp;user)<br>	err := dbmap.SelectOne(&amp;user, &quot;select * from user where Username=? LIMIT 1&quot;, user.Username)</pre><pre>	if err == nil {<br>		user_id := user.Id</pre><pre>		content := &amp;models.User{<br>			Id:        user_id,<br>			Username:  user.Username,<br>			Password:  user.Password,<br>			Firstname: user.Firstname,<br>			Lastname:  user.Lastname,<br>		}<br>		c.JSON(200, content)<br>	} else {<br>		c.JSON(404, gin.H{&quot;error&quot;: &quot;user not found&quot;})<br>	}</pre><pre>}</pre><pre>func PostUser(c *gin.Context) {<br>	var user models.User<br>	c.Bind(&amp;user)</pre><pre>	log.Println(user)</pre><pre>	if user.Username != &quot;&quot; &amp;&amp; user.Password != &quot;&quot; &amp;&amp; user.Firstname != &quot;&quot; &amp;&amp; user.Lastname != &quot;&quot; {</pre><pre>		if insert, _ := dbmap.Exec(`INSERT INTO user (Username, Password, Firstname, Lastname) VALUES (?, ?, ?, ?)`, user.Username, user.Password, user.Firstname, user.Lastname); insert != nil {<br>			user_id, err := insert.LastInsertId()<br>			if err == nil {<br>				content := &amp;models.User{<br>					Id:        user_id,<br>					Username:  user.Username,<br>					Password:  user.Password,<br>					Firstname: user.Firstname,<br>					Lastname:  user.Lastname,<br>				}<br>				c.JSON(201, content)<br>			} else {<br>				checkErr(err, &quot;Insert failed&quot;)<br>			}<br>		}</pre><pre>	} else {<br>		c.JSON(400, gin.H{&quot;error&quot;: &quot;Fields are empty&quot;})<br>	}</pre><pre>}</pre><pre>func UpdateUser(c *gin.Context) {<br>	id := c.Params.ByName(&quot;id&quot;)<br>	var user models.User<br>	err := dbmap.SelectOne(&amp;user, &quot;SELECT * FROM user WHERE id=?&quot;, id)</pre><pre>	if err == nil {<br>		var json models.User<br>		c.Bind(&amp;json)</pre><pre>		user_id, _ := strconv.ParseInt(id, 0, 64)</pre><pre>		user := models.User{<br>			Id:        user_id,<br>			Username:  user.Username,<br>			Password:  user.Password,<br>			Firstname: json.Firstname,<br>			Lastname:  json.Lastname,<br>		}</pre><pre>		if user.Firstname != &quot;&quot; &amp;&amp; user.Lastname != &quot;&quot; {<br>			_, err = dbmap.Update(&amp;user)</pre><pre>			if err == nil {<br>				c.JSON(200, user)<br>			} else {<br>				checkErr(err, &quot;Updated failed&quot;)<br>			}</pre><pre>		} else {<br>			c.JSON(400, gin.H{&quot;error&quot;: &quot;fields are empty&quot;})<br>		}</pre><pre>	} else {<br>		c.JSON(404, gin.H{&quot;error&quot;: &quot;user not found&quot;})<br>	}<br>}</pre><p>Well, we write enough code, let try to build the app and test it, I’m going test it using chrome extension Postman (you can use any REST client like curl to test).</p><p>To build the app open your terminal and go the the <em>main</em> directory</p><pre>$ go build main.go</pre><p>The command will build a binary file main and to run the file us this command $ .main/main.go . Wow, our example project app is running on port: 8080. It’ll display the debug log, because by default gin run’s in debug mode and port 8080.</p><p>To test the api run postman and test the api sequentiall</p><p><em>Fetch All Users</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3MAnIEUwamhZz0F3zyMocw.png" /></figure><p><em>Fetch Single User</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*vprdViGBWmUivuHiPxk3Ew.png" /></figure><p><em>Post a User</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*LnnclTfQRQ8KAGrZJ8Kssw.png" /></figure><p><em>Login User</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*CWHbO8jX8fbXuZlPj1DYHA.png" /></figure><p>You can see <strong>Gin Gonic Mysql Golang Example</strong> in <a href="https://github.com/eccosuprastyo/go/tree/master/gin-login">Here</a>.</p><p>Thank you for reading this article about <a href="https://camellabs.com/gin-gonic-mysql-golang-example/"><strong>Gin Gonic Mysql Golang Example</strong></a>, I hope this article is useful for you. Visit My Github about Go in <a href="https://github.com/eccosuprastyo/go">Here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9185f202e968" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>