Issue There is a _ operator which makes a property private. Eg: _hidden() This hides the property outside of the file. Now if I have a Parent class with func() in the file parent.dart. A Child class extends the Parent
Continue readingTag: oop
Dart fails to infer type of sub class
Issue I have this code that I’ve reduced to the file below. import ‘package:hooks_riverpod/hooks_riverpod.dart’; // this class disctates what other classes do abstract class BaseUtils<T> { T fromMap(Map<String, dynamic> json); } // Model to be used class SampleModel extends BaseUtils
Continue readingWhy do we have implements in dart?
Issue I can’t get a clue why do we need implements? According to this https://dart.dev/language/classes#implicit-interfaces After we used implements we should rewrite everything we have in parent class except constructor. // A person. The implicit interface contains greet(). class Person
Continue readingDisplay attribute of List item in a ListView in Flutter
Issue I am creating a small Flutter program to get to know it but cannot display the ‘description’ attribute of a ‘Task’ object (which exists in a List) using a ListView Builder. I have tried it with ordinary text and
Continue readingis dartz Either Nesisty or just matter of taste?
Issue So before I start I,m a beginner in Flutter and in programming all together. I used to just follow video tutorials and consider their best practices, one of my earliest tutorials introduced me to the Dartz library and it
Continue readingAdding functions inside model breaks MVVM or SOLID principles in Dart / Flutter
Issue In Dart we add methods like toJson() and Model.fromJson() inside model, does this breaks MVVM or SOLID principles? Solution No, it doesn’t, it’s totally the opposite, it’s recommended to set model JSON converters factories and methods of a model
Continue readingRight way to group initialization code in Java
Issue I have some stuff with similar properties, methods and initialization code. Like public class LoadElement { LoadingElementBinding binding; public LoadElement(ViewGroup parent) { binding = LoadingElementBinding.inflate( LayoutInflater.from(parent.getContext()), parent, false)); binding.setLifecycleOwner(ViewTreeLifecycleOwner.get(parent)); } public void doDomething() { //somehing do with binding }
Continue readingNot able to update a list with set state in textfield onchanged method
Issue i want to update a list of songmodel when i enter a value in textfield with on changed model the value is not updating of list with set state method List<SongModel> songs = item.data!; List<SongModel> filterSongs = []; //showing
Continue readingWhat does class ClassName<int>{} means in Dart?
Issue class MyBloc extends Bloc<MyEvent, MyState> { MyBloc() : super(StateA()) { on<EventA>((event, emit) => emit(StateA())); on<EventB>((event, emit) => emit(StateB())); } } How Bloc use <MyEvent, MyState> under the hood? Solution I think you are searching for generics. Here is a
Continue readingComparing between two same objects returning false
Issue I have list of objects and I need to see if the new object is already in the list. So, I make condition if the list contains the new object, it’s returning false ,even though I print the list
Continue reading