Skip to main content

Keep Your Promises: The Liskov Substitution Principle Made Simple

If you're learning clean code, you'll keep running into the "SOLID" principles. The L stands for the Liskov Substitution Principle (LSP) — a scary name for a genuinely simple idea. This guide starts from zero, so no prior knowledge is needed. What it is The Liskov Substitution Principle says: If something is supposed to work like a certain type, then any "version" of that type must be able to take its place without causing problems. That's the whole thing. If you call something a Doctor , it has to actually behave like a doctor everywhere a doctor is expected. If you call something an ApiClient , it has to behave like one everywhere. Break that, and your program fails — usually later, in a confusing way. The principle is named after Barbara Liskov, a computer scientist who described it back in 1987. But you don't need the academic version to use it well. First, what does "substitute" mean? This is the word that makes the whole pr...

ListView and ListTile!

Listview and Listtile are basic widgets, which are used to make a scrollable lists of item in a mobile app. They are essential component for building app where we need various type of lists, such as menus, chat message lists and etc.



ListView: Listview is a widget used to create a scrollable list of children. It can hold a list of widgets and automatically handles scrolling when the content exceeds the available space.

ListTile: Listtile widget is designed to represent a single item within a list. It typically contains title, subtitle, leading or trailing icon and can be made tappable.

Key Properties of listTile:

  • Title: The primary content of the list item.
  • Subtitle: Optional secondary content.
  • leading: A widget display before the title.
  • trailing: A widget display after the title.
  • Ontap: A callback function that is triggered when the listtile tapped.

Both Listview and Listtile are highly customizable, and you can style them according to the app design requirements. They are versatile and widely used in Flutter app development for presenting list of data or options to users in an organized and user-friendly manner.

body: Container(
margin: const EdgeInsets.fromLTRB(0, 10, 8, 0),
child: ListView(
itemExtent: 70.0,
children: [
ListTile(
title: Text(
"Top Faculties(UITS)",
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold, color: Colors.red),
textAlign: TextAlign.center,
),
),
ListTile(
leading: Container(
height: double.infinity,
child: Icon(Icons.computer)
),
title: Text(
"Computer Science",
style: TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text("We are the first it university......"),
trailing: Text("300000"),
onTap: () {},
),
ListTile(
leading: Container(
height: double.infinity,
child: Icon(Icons.medical_information)
),
title: Text(
"Pharmacy",
style: TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text("We have best medicine......"),
trailing: Text("450000"),
onTap: (){},
),
ListTile(
leading: Container(
height: double.infinity,
child: Icon(Icons.electric_bolt)
),
title: Text(
"Electrical Engineering",
style: TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text("Our students works at best....."),
trailing: Text("500400"),
onTap: (){},
)
],
),
),

Comments

Popular posts from this blog

Keep Your Promises: The Liskov Substitution Principle Made Simple

If you're learning clean code, you'll keep running into the "SOLID" principles. The L stands for the Liskov Substitution Principle (LSP) — a scary name for a genuinely simple idea. This guide starts from zero, so no prior knowledge is needed. What it is The Liskov Substitution Principle says: If something is supposed to work like a certain type, then any "version" of that type must be able to take its place without causing problems. That's the whole thing. If you call something a Doctor , it has to actually behave like a doctor everywhere a doctor is expected. If you call something an ApiClient , it has to behave like one everywhere. Break that, and your program fails — usually later, in a confusing way. The principle is named after Barbara Liskov, a computer scientist who described it back in 1987. But you don't need the academic version to use it well. First, what does "substitute" mean? This is the word that makes the whole pr...

Understanding BuildContext in Flutter!

As a Flutter developer, you might have encountered the term BuildContext early in your journey. Despite its importance, many developers struggle to grasp its full significance. Today, we’re going to dive into what BuildContext is, what it does, and why it’s crucial for running your Flutter app. What is BuildContext In both stateless and stateful widgets, when you override the build method, it takes BuildContext context as a parameter. This context is provided by the Flutter framework. Here’s a simple example to illustrate: Widget build(BuildContext context) { return OutlinedButton( onPressed: () async { await Future< void >.delayed( const Duration(seconds: 1 )); if (context.mounted) { Navigator.of(context).pop(); } }, child: const Text( 'Delayed pop' ), ); } BuildContext do a simple task, track all of your widget location. In flutter, it all about widgets. Everything is build on a collection of widgets. Some widgets are parent w...

Impeller: Elevating Flutter Performance with Predictable Rendering

In the world of Flutter, Impeller is a buzzword that has caught the attention of developers and enthusiasts alike. But what exactly is Impeller, and why is it crucial for Flutter apps? Let’s dive into the details. What is Impeller? Impeller is a new rendering engine for flutter. Now, many of you can think. What is a rendering engine. Rendering engine is nothing but a piece of software responsible for converting input instructions or data into visual or audible output. Basically , it helps us to draw UI of an app according to the instruction you give it. Flutter engine is written is C/C++language. Which is the part of dart UI. Rendering engine in Flutter orchestrates the transformation from widget tree to pixels on the screen. Before Impeller flutter used skia as a default graphics engine. But, there was some issues on it. Challenges with Skia: Skia has been the graphic engine for Flutter since its inception. Skia is also a powerful render engine, which powers various platforms, inc...