Posts

Showing posts from December, 2023

CheckboxListTile Dynamic

  import "package:flutter/material.dart" ; void main () { runApp( MyApp ()) ; } class MyApp extends StatelessWidget { MyApp({ super .key}) ; @override Widget build (BuildContext context) { return MaterialApp ( title: "Dynamic checkboxListTile" , debugShowCheckedModeBanner: false, theme: ThemeData ( primarySwatch: Colors. grey , ) , home: DynamicTile () , ) ; } } class DynamicTile extends StatefulWidget { DynamicTile({ super .key}) ; @override State<DynamicTile> createState () { return DynamicTileState () ; } } class DynamicTileState extends State<DynamicTile> { List<Map> categories = [ { "name" : "Swimming" , "isChecked" : false } , { "name" : "Cycling" , "isChecked" : false } , { "name" : "Tennis" , "isChecked" : false } , { "name" : "Boxing" , "is...

CheckboxListTile

  import "package:flutter/material.dart" ; void main () { runApp( const MyApp ()) ; } class MyApp extends StatelessWidget { const MyApp({ super .key}) ; @override Widget build (BuildContext context) { return MaterialApp ( title: "CheckBoxListTile" , debugShowCheckedModeBanner: false, theme: ThemeData ( primarySwatch: Colors. grey , ) , home: const CheckPractice () , ) ; } } class CheckPractice extends StatefulWidget { const CheckPractice({ super .key}) ; @override State<CheckPractice> createState () => _CheckPracticeState () ; } class _CheckPracticeState extends State<CheckPractice> { /// value set to false bool _value1 = false; @override Widget build (BuildContext context) { return Scaffold ( appBar: AppBar ( title: const Text ( "CheckBoxListTile" ) , centerTitle: true, backgroundColor: Colors. grey , ) , body: Center ( ...

Get CLI Commands in GetX

  /// Get CLI tool /// ================== /// Make flutter development easy with GetX and Get CLI tool /// /// 1. Install /// ================== /// flutter pub global activate get_cli /// /// 2. Create project /// ================== /// get create project /// /// a. If no project name is specified it will take the folder name as project name /// b. get create project:get_cli_project [project with name] /// c. get create project:"get cli project" [project name with space] /// /// 3. To create the structure /// =========================== /// get init /// /// 4. Create a page /// =========================== /// get create a page:page_name [will create controller, view and binding] /// /// 5. Create Controller /// =========================== /// a. get create controller:controllerName [By default in home folder] /// b. get create controller:controllerName on folderName /// /// 6. Create View /// ====================================== /// a. get create view:ViewName [By defaul...

DialogBox in GetX

  import "package:flutter/material.dart" ; import "package:get/get.dart" ; void main () { runApp( MyApp ()) ; } class MyApp extends StatelessWidget { MyApp({ super .key}) ; @override Widget build (BuildContext context) { return GetMaterialApp ( title: "Dialog Box" , debugShowCheckedModeBanner: false, theme: ThemeData ( primarySwatch: Colors. blue , ) , home: PracticeDialog () , ) ; } } class PracticeDialog extends StatelessWidget { PracticeDialog({ super .key}) ; @override Widget build (BuildContext context) { return Scaffold ( appBar: AppBar ( title: const Text ( "DialogBox in GetX" ) , centerTitle: true, backgroundColor: Colors. grey , ) , body: Center ( child: Column ( mainAxisAlignment: MainAxisAlignment. center , crossAxisAlignment: CrossAxisAlignment. center , children: <Widget>[ ...

Snackbar using GetX

  import "package:flutter/material.dart" ; import "package:get/get.dart" ; void main () { runApp( const MyApp ()) ; } class MyApp extends StatelessWidget { const MyApp({ super .key}) ; @override Widget build (BuildContext context) { return GetMaterialApp ( title: "Snack bar using Getx" , debugShowCheckedModeBanner: false, theme: ThemeData ( primarySwatch: Colors. grey , ) , home: const PracticeSnackbar () , ) ; } } class PracticeSnackbar extends StatelessWidget { const PracticeSnackbar({ super .key}) ; @override Widget build (BuildContext context) { return Scaffold ( appBar: AppBar ( title: const Text ( "Snackbar using GetX" ) , centerTitle: true, backgroundColor: Colors. grey , ) , body: Center ( child: Column ( mainAxisAlignment: MainAxisAlignment. center , crossAxisAlignment: CrossAxisAlignment. center , ...

Route Navigation for Unnamed Routes in GetX

  import "package:firebase/GetX/HomeScreen.dart" ; import "package:flutter/material.dart" ; import "package:get/get.dart" ; void main () { runApp( const MyApp ()) ; } class MyApp extends StatelessWidget { const MyApp({ super .key}) ; @override Widget build (BuildContext context) { return GetMaterialApp ( title: "Route Navigation for Unnamed Routes" , debugShowCheckedModeBanner: false, theme: ThemeData ( primarySwatch: Colors. blue , ) , home: const GetXDemo () , ) ; } } class GetXDemo extends StatelessWidget { const GetXDemo({ super .key}) ; @override Widget build (BuildContext context) { return Scaffold ( appBar: AppBar ( title: const Text ( "GetX Route Navigation for Unnamed Routes" ) , centerTitle: true, backgroundColor: Colors. grey , ) , body: Center ( child: Column ( mainAxisAlignment: MainAxisAlignment. ce...

Dependency Injection in GetX

  import "package:firebase/GetX/Controller.dart" ; import "package:flutter/material.dart" ; import "package:get/get.dart" ; void main () { runApp( MyApp ()) ; } class MyApp extends StatelessWidget { MyApp({ super .key}) ; @override Widget build (BuildContext context) { return GetMaterialApp ( title: "Dependency Injection" , debugShowCheckedModeBanner: false, theme: ThemeData ( primarySwatch: Colors. brown , ) , home: DependencyInjection () , ) ; } } class DependencyInjection extends StatelessWidget { DependencyInjection({ super .key}) ; /// My Controller instance will be created even if it is not used tag will be used /// to find the instance with tag name Controller disposed when it is not used but if /// permanent is true the instance will be alive throughout the app // MyController myController = Get.put(MyController(), tag: "instance1", permanent: true); @override ...

GetX Notes

  // You can use GetBuilder, GetX, or Obx in different situations during Flutter app development: // // GetBuilder: You can use GetBuilder when you want to update only a small portion of // your widget's view based on specific state changes. // For example, if you have multiple states managed within a controller and only want to update // a few widgets that depend on those states, you can use GetBuilder to build those specific widgets. // // GetX: GetX combines the features of GetBuilder, Obx, and other functionalities provided by GetX. // You can use GetX when you want to observe state changes and automatically update // the widgets that depend on them. GetX performs better as it only updates the necessary widgets. // // Obx: Obx stands for "Observer Widget". You can use Obx when you want to update all the widgets // associated with the observed state. Obx will automatically rebuild the widget // whenever there is a change in the observed state. This is useful when you h...

custom Font

  import "package:flutter/material.dart" ; void main () { runApp( const MyApp () , ) ; } class MyApp extends StatelessWidget { const MyApp({ super .key}) ; @override Widget build (BuildContext context) { return MaterialApp ( debugShowCheckedModeBanner: false, title: "Custom Font in Flutter" , theme: ThemeData ( primarySwatch: Colors. purple , ) , home: const FontDemo () , ) ; } } class FontDemo extends StatefulWidget { const FontDemo({ super .key}) ; @override State<FontDemo> createState () { return FontState () ; } } class FontState extends State<FontDemo> { @override Widget build (BuildContext context) { return Scaffold ( appBar: AppBar ( title: const Text ( "Custom Font" ) , ) , body: const Center ( child: Column ( mainAxisAlignment: MainAxisAlignment. center , children: [ Text ( "Hello World...