<?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 Flutter Mania on Medium]]></title>
        <description><![CDATA[Stories by Flutter Mania on Medium]]></description>
        <link>https://medium.com/@ghakare?source=rss-3eab14acfc9f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DaYqTFIx-p58HCXr9B19kw.png</url>
            <title>Stories by Flutter Mania on Medium</title>
            <link>https://medium.com/@ghakare?source=rss-3eab14acfc9f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 22:54:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ghakare/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[Flutter Interview Questions: Basic to Expert — Part 1]]></title>
            <link>https://medium.com/@ghakare/flutter-interview-questions-basic-to-expert-part-1-0f1bb9c32e04?source=rss-3eab14acfc9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f1bb9c32e04</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-interview]]></category>
            <category><![CDATA[flutter-web]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <dc:creator><![CDATA[Flutter Mania]]></dc:creator>
            <pubDate>Sat, 29 Aug 2026 14:26:38 GMT</pubDate>
            <atom:updated>2026-08-29T14:26:38.727Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>1] What is Dart, and why does Flutter use it?</strong><br>Dart is a programming language created by Google on which Flutter is built. It is object-oriented and strongly typed, with sound null safety. Flutter chose Dart mainly for its two compilation modes.<br>During development, it uses JIT (Just-In-Time) compilation, which makes hot reload possible. For the release build, it uses AOT (Ahead-Of-Time) compilation, which converts the code to native machine code, so the app starts fast and runs fast.<br>One more important point I always mention is that Dart has a single-threaded event loop with<br>isolates for concurrency, and it allocates objects very efficiently, which suits the UI work<br>where we are creating and throwing away widget objects constantly.</p><p><strong>2] What is the difference between a StatelessWidget and a StatefulWidget?<br></strong>A StatelessWidget does not change once it is built. Whatever data it needs comes through its constructor, and if that data does not change during the widget’s life, we use a stateless. A good example is a label that just shows a title.<br>A StatefulWidget is used when the UI needs to change over time because of user interaction<br>or some internal data change — for example, a counter, a form, or a checkbox. <br><em>The key thing we always need to clarify in interviews is that the StatefulWidget itself is also immutable; the mutable part lives in a separate State object. When we call setState, the framework keeps the same<br>State object but rebuilds the widget.</em></p><pre>class Counter extends StatefulWidget {<br>const Counter({super.key});<br>@override<br>State&lt;Counter&gt; createState() =&gt; _CounterState();<br>}<br><br>class _CounterState extends State&lt;Counter&gt; {<br>int _count = 0;<br>void _increment() =&gt; setState(() =&gt; _count++);<br>}</pre><p><strong>3] What are the three trees in Flutter: Widget, Element, and RenderObject?<br></strong>This is a very important internal concept. Flutter actually maintains three parallel trees.<br>The <strong>Widget tree</strong> is what we write in code. Widgets are lightweight, immutable configuration objects, and they are created and destroyed very frequently — on every rebuild.<br>The <strong>Element tree</strong> is the bridge. An Element is the actual instance that Flutter keeps in memory. It holds a reference to its widget and to its render object, and it manages the lifecycle and the position in the tree. Elements are long-lived and are reused across rebuilds, which is why Flutter is fast.<br>The <strong>RenderObject </strong>tree is the one that does the heavy work — layout, painting, and hit-testing. These are also expensive to create, so Flutter reuses them.</p><p><strong>4] What is the role of main() and runApp() ?<br>main()</strong> is the entry point of any Dart program, the same as in other languages. Inside main, we call<strong> runApp()</strong> and pass it the root widget. <strong>runApp()</strong> takes that widget and attaches it to the screen, making it the root of the widget tree.<br><em>One small but good point to mention is that if we are doing any asynchronous initialisation before runApp — like Firebase initialisation or reading shared preferences — we must first call </em><strong><em>WidgetsFlutterBinding.ensureInitialized(),</em></strong><em> otherwise the binding is not ready, and it will throw an error.</em></p><p><strong>5] What is the difference between hot reload and hot restart?<br></strong>Hot reload injects the updated source code into the running Dart VM and rebuilds the widget tree, but it preserves the current application state. So if I am on screen three of a flow and I change a colour, hot reload will keep me on screen three. It is very fast, usually under a second.</p><p>Hot restart, on the other hand, restarts the whole app, throwing away all the state and starting from the root again. <br><em>We use hot restart when we change something that hot reload cannot pick up — like changes in main(), global variables, static fields, or the state class structure itself.</em></p><p><strong>6] What is BuildContext, and why is it important?<br></strong>BuildContext is essentially a handle to the location of a widget in the element tree. Every widget’s build method receives this context. Through it, Flutter knows where the widget sits in the tree.<br>It becomes important because we use it to look up things from ancestors, for example <strong>Theme. of (context),</strong> <strong>MediaQuery.of (context)</strong>, of(context), <strong>Navigator. of(context),</strong> or <strong>Provider. of(context)</strong>. All of these walk up the tree from the current context to find the nearest matching ancestor. A very common mistake juniors make, and which interviewers test, is using a context that is above the widget they are trying to find — for example calling<br>ScaffoldMessenger.of(context) with the context of the same build method that created the Scaffold, which then fails to find it. The fix is usually a Builder widget to get a context below that ancestor.</p><p><strong>7] What does the const keyword do for widgets, and why does it matter?<br></strong>When we mark a widget as const, Dart creates it at compile time and reuses the same instance. The big benefit is for performance: when Flutter rebuilds a parent, a const child widget is identical, so Flutter can skip rebuilding that subtree entirely.<br>So in my projects I make it a habit to add const wherever the widget and all its parameters are compile-time constants. It is one of the easiest and cheapest performance wins, and the linter usually suggests it too.</p><p><strong>8] Explain sound null safety in Dart.<br></strong>Null safety means that by default a variable cannot hold null unless we explicitly allow it. So String name can never be null, but String? name can be. This shifts a whole class of null- reference crashes from runtime to compile time, which is a huge reliability improvement.</p><p>The operators I use daily are: the ? for nullable types, the! bang operator to assert non-null when I am sure, the ?? to provide a default, the ?. for safe member access, and late for a non-nullable variable that I promise to initialise before first use. I always caution against<br>overusing the bang operator, because it bypasses the safety the compiler is giving us.</p><p><strong>9] What is the difference between final and const in Dart?<br></strong>Both create variables that cannot be reassigned. The difference is timing. A const value must be known at compile time — it is a true compile-time constant. A final value can be assigned at runtime, but only once. So final time = DateTime.now() is valid because the value is known at runtime, whereas const time = DateTime.now() would be an error.</p><p><strong>10] What are mixins and extensions, and when do you use them?<br></strong>it with the mixin keyword and brought in using the with keyword. In Flutter, a very common one is SingleTickerProviderStateMixin, which we add to a State class to provide a ticker for animations.<br>An extension lets us add new methods to an existing class that we do not own. For example, I often write an extension on BuildContext so that instead of writing MediaQuery.of(context).size.width everywhere, I can simply write context.width. It keeps the code very readable.</p><pre>extension ContextExt on BuildContext {<br>double get width =&gt; MediaQuery.of(this).size.width;<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f1bb9c32e04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Protobuf and gRPC in Flutter App Development]]></title>
            <link>https://medium.com/@ghakare/protobuf-and-grpc-in-flutter-app-development-9e69dff68a2f?source=rss-3eab14acfc9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e69dff68a2f</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[protobuf-and-grpc]]></category>
            <category><![CDATA[crossplatform-mobile-app]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter-api]]></category>
            <dc:creator><![CDATA[Flutter Mania]]></dc:creator>
            <pubDate>Mon, 10 Aug 2026 15:47:06 GMT</pubDate>
            <atom:updated>2026-08-10T15:47:06.975Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern Flutter applications usually don’t work alone. They need to communicate with backend services to fetch data, send updates, handle real-time communication, and provide a smooth user experience. REST APIs with JSON are still very common, but in applications where performance, real-time communication, and strong API contracts are important, <strong>Protobuf and gRPC</strong> can be a good alternative.</p><h3><strong>1. The Protobuf &amp; gRPC Glow-Up: What’s the Hype?</strong></h3><h4>Protobuf (Protocol Buffers)</h4><p>Protobuf, or Protocol Buffers, is a data serialization format developed by Google. Instead of manually creating JSON objects and converting them into Dart models, we define the structure of our data in a .proto file.</p><p>For example, we can define a user with fields such as id, name, and email. From this .proto file, code can be generated for different languages such as Dart, Java, Kotlin, Go, or Python.</p><p>One of the main advantages of Protobuf is that it uses a compact binary format. Because of this, the data is generally smaller than JSON and can be processed efficiently.</p><h4>gRPC</h4><p>gRPC is a framework used for communication between a client and a server. It commonly uses Protobuf to define the request and response messages and HTTP/2 for communication.</p><p>The main difference in the way we think about gRPC is that, instead of calling REST endpoints such as:</p><p>GET /users/101</p><p>we can define a service method such as:</p><p>GetUser(UserRequest)</p><p>The generated client then allows the Flutter application to call that remote method almost like a normal function.</p><p>So, in simple terms:</p><ul><li><strong>Protobuf</strong> defines how the data is structured.</li><li><strong>gRPC</strong> defines how the client and server communicate using that data.</li></ul><p>They are commonly used together, but Protobuf can also be used independently.</p><h3>2. Where can Protobuf and gRPC be used in Flutter?</h3><p>Protobuf and gRPC are useful when a Flutter app needs <strong>fast, efficient, and strongly typed communication</strong> with a backend.</p><p>They work well for:</p><p><strong>Real-time features</strong> like chat and live tracking.</p><ul><li><strong>High-performance apps</strong> where low latency and smaller payloads matter.</li><li><strong>Cross-language backends</strong>, where the same .proto contract can be shared between Flutter and services written in Go, Java, Python, etc.</li></ul><p>For simple CRUD or public APIs, <strong>REST + JSON</strong> can still be a simpler choice.</p><h3>3. How does it work in a Flutter application?</h3><p>The first step is to create a .proto file that defines our messages and services.</p><p>For example:</p><pre>syntax = &quot;proto3&quot;;</pre><pre>package user;</pre><pre>message UserRequest {<br>  int32 id = 1;<br>}</pre><pre>message UserResponse {<br>  int32 id = 1;<br>  string name = 2;<br>  string email = 3;<br>}</pre><pre>service UserService {<br>  rpc GetUser (UserRequest) returns (UserResponse);<br>}</pre><p>Here, we have created a UserRequest and UserResponse. We have also defined a UserService with a GetUser method.</p><p>The important part here is the field number.</p><p>For example:</p><pre>string name = 2;</pre><p>The number 2 is the field&#39;s unique tag. These numbers are important for Protobuf compatibility and should not be changed or reused once they are part of an established contract.</p><p>After creating the .proto file, we use the Protobuf compiler and Dart plugin to generate the required Dart classes and gRPC client code.</p><p>For example:</p><pre>protoc --dart_out=grpc:lib/generated -Iproto proto/user.proto</pre><p>This generates Dart files that we can use directly inside our Flutter application.</p><p>We can then create a service class around the generated gRPC client:</p><pre>import &#39;package:grpc/grpc.dart&#39;;<br>import &#39;generated/user.pbgrpc.dart&#39;;</pre><pre>class UserApiService {<br>  late UserServiceClient _client;</pre><pre>  UserApiService() {<br>    final channel = ClientChannel(<br>      &#39;your-server-host.com&#39;,<br>      port: 443,<br>      options: const ChannelOptions(<br>        credentials: ChannelCredentials.secure(),<br>      ),<br>    );</pre><pre>    _client = UserServiceClient(channel);<br>  }</pre><pre>  Future&lt;UserResponse&gt; fetchUser(int id) async {<br>    final request = UserRequest()..id = id;</pre><pre>    return await _client.getUser(request);<br>  }<br>}</pre><p>Then from the application, we can call:</p><pre>final userApiService = UserApiService();</pre><pre>void loadUser() async {<br>  final user = await userApiService.fetchUser(101);</pre><pre>  print(&#39;Name: ${user.name}&#39;);<br>  print(&#39;Email: ${user.email}&#39;);<br>}</pre><p>The important difference here is that we don’t have to create them manually fromJson() and toJson() methods for these Protobuf messages. The generated classes already handle the serialization and deserialization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e69dff68a2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>