Posts

Showing posts from February, 2024

While Loop Programmes Practice

  import "dart:io" ; /// Program 1 : /// Program of printing numbers from 0 to 10 as shown below: // void main() // { // int i = 0; // while(i <= 10) // { // stdout.write(i); // i++; // stdout.write("\n"); // } // } /// Program 2 : /// Program of printing numbers from 10 to 0 as shown below: // void main() // { // int i = 10; // while(i >= 0) // { // stdout.write(i); // i--; // stdout.write("\n"); // } // } /// Program 3 : /// Program of printing Even numbers between the 0 to user Entered number as shown below: // void main() // { // stdout.write("Enter the Number : "); // double num = double.parse(stdin.readLineSync()!); // double i = 0; // while(i <= num) // { // if(i%2 == 0) // { // stdout.write(i); // stdout.write("\n"); // } // i++; // } // } /// Program 4 : /// Program of printing Odd numbers between the 0 to user Entered number as sho...

For Loop Programmes Practice

  import 'dart:io' ; /// Program 1 : /// Program of printing numbers from 0 to 10 as shown below: // void main() // { // for(int i = 0; i <= 10; i++) // { // stdout.write(i); // stdout.write("\n"); // } // } /// Program 2 : /// Program of printing numbers from 10 to 0 as shown below: // void main() // { // for(int i = 10; i >= 0; i--) // { // stdout.write(i); // stdout.write("\n"); // } // } /// Program 3 : /// Program of printing Even numbers between the 0 to user Entered number as shown below: // void main() // { // stdout.write("Enter the Number : "); // double num = double.parse(stdin.readLineSync()!); // for(double i = 0; i <= num; i++) // { // if(i%2 == 0) // { // stdout.write(i); // stdout.write("\n"); // } // } // } /// Program 4 : /// Program of generating the simple pattern program as shown below: // void main() // { // ...

Shared Preferences Get and Set String Data simple Example

  import "package:flutter/material.dart" ; import "package:shared_preferences/shared_preferences.dart" ; void main () { runApp( const MyApp ()) ; } class MyApp extends StatelessWidget { const MyApp({ super .key}) ; @override Widget build (BuildContext context) { return MaterialApp ( title: "Shared Preferences" , debugShowCheckedModeBanner: false, theme: ThemeData ( primarySwatch: Colors. grey , ) , home: const SharedPractice () , ) ; } } class SharedPractice extends StatefulWidget { const SharedPractice({ super .key}) ; @override State<SharedPractice> createState () { return SharedPracticeState () ; } } class SharedPracticeState extends State<SharedPractice> { final TextEditingController _controller = TextEditingController () ; String _savedText = "" ; @override void initState () { _getText() ; super .initState() ; } Future< void > _getTe...

Bloc (State Management) MultiBlocListener and MultiRepositoryProvider

  import "package:flutter/material.dart" ; /// MultiBlocListener : /// It is a widget provided by flutter_bloc library. It merges multiple BlocListener widget into one and /// hence improves the readability of code. /// CODE: /// MultiBlocListener( /// listeners: [ /// BlocListener<BlocA, BlocAState>( /// listener: (context, state) {}, /// ), /// BlocListener<BlocB, BlocBState>( /// listener: (context, state) {}, /// ), /// BlocListener<BlocC, BlocCState>( /// listener: (context, state) {}, /// ), /// ], /// child: ChildA(), /// ) /// MultiRepositoryProvider : /// It is a widget provided by flutter_bloc library. It merges multiple RepositoryProvider widget into one /// and hence improves the readability of code. /// CODE: /// MultiRepositoryProvider( /// providers: [ /// RepositoryProvider<RepositoryA>( /// create: (context) { return RepositoryA(); }, /// ), /// RepositoryProvider<RepositoryB>( /// create: (context) { return RepositoryB(); }, ///...

Bloc (State Management) BlocSelector Counter App using BlocSelector Functionality

  class CounterState { final int count ; CounterState({ required this . count }) ; } sealed class CounterEvent {} final class CounterIncrementEvent extends CounterEvent {} final class CounterDecrementEvent extends CounterEvent {} import "package:bloc_state_management/bloc_ripples_code/counter_event.dart" ; import "package:bloc_state_management/bloc_ripples_code/counter_state.dart" ; import "package:flutter_bloc/flutter_bloc.dart" ; class CounterBloc extends Bloc<CounterEvent , CounterState> { CounterBloc() : super ( CounterState (count: 0 )) { on<CounterIncrementEvent>((event , emit) { return emit( CounterState (count: state . count + 1 )) ; } , ) ; on<CounterDecrementEvent>((event , emit) { return emit( CounterState (count: state . count - 1 )) ; } , ) ; } } import "package:bloc_state_management/bloc_ripples_code/counter_bloc.dart" ; import "package:bloc_state_management/bloc_ripples_cod...

Bloc (State Management) Bloc Consumer Counter App with Visibility Event

  class CounterState { final int count ; CounterState({ required this . count }) ; } sealed class CounterEvent {} final class CounterIncrementEvent extends CounterEvent {} final class CounterDecrementEvent extends CounterEvent {} import "package:bloc_state_management/bloc_ripples_code/counter_event.dart" ; import "package:bloc_state_management/bloc_ripples_code/counter_state.dart" ; import "package:flutter_bloc/flutter_bloc.dart" ; class CounterBloc extends Bloc<CounterEvent , CounterState> { CounterBloc() : super ( CounterState (count: 0 )) { on<CounterIncrementEvent>((event , emit) { return emit( CounterState (count: state . count + 1 )) ; } , ) ; on<CounterDecrementEvent>((event , emit) { return emit( CounterState (count: state . count - 1 )) ; } , ) ; } } class VisibilityState { final bool show ; VisibilityState({ required this . show }) ; } sealed class VisibilityEvent {} final class Visibility...

Bloc (State Management) Bloc Listener Counter App with MultiBlocProvider with Visibility Event

  class CounterState { final int count ; CounterState({ required this . count }) ; } sealed class CounterEvent {} final class CounterIncrementEvent extends CounterEvent {} final class CounterDecrementEvent extends CounterEvent {} import "package:bloc_state_management/bloc_ripples_code/counter_event.dart" ; import "package:bloc_state_management/bloc_ripples_code/counter_state.dart" ; import "package:flutter_bloc/flutter_bloc.dart" ; class CounterBloc extends Bloc<CounterEvent , CounterState> { CounterBloc() : super ( CounterState (count: 0 )) { on<CounterIncrementEvent>((event , emit) { return emit( CounterState (count: state . count + 1 )) ; } , ) ; on<CounterDecrementEvent>((event , emit) { return emit( CounterState (count: state . count - 1 )) ; } , ) ; } } class VisibilityState { final bool show ; VisibilityState({ required this . show }) ; } sealed class VisibilityEvent {} final class Visibility...