I loved your approach of coloring the buttons, here's what I followed: text color property (will become purple based on setColor's condition): var textColor = Colors.white; instance method of the custom button class: void setColor(String value) { if (buttonText == 'C') { buttonColor = Colors.green; } else if (buttonText == 'DEL') { buttonColor = Colors.red; } else if ('%/x-+='.split('').contains(buttonText)) { buttonColor = Colors.deepPurple; } else { buttonColor = Colors.white; textColor = Colors.deepPurple; } } builder method of the gridview: (context, index) { var button = MyButton( buttonText: buttons[index] ); button.setColor(buttons[index]); return button; }
if any one is getting error ..... add this line in starting the video was cut when he add this line import 'package:calculator/buttons.dart'; (replace calculator with your project name)
Nice tutorial bro but I have one question. When you created List those all were strings but if I want to add different types in the same list is it possible to do so? For Example: List data = ['clear' , Icons.backspace, '9']; this results in type icon is not a sub type of string. I tried this also but can't get the result I wanted: List data = ['clear' , Icons.backspace, '9']; How to add integers, string, icon, and many more data types in the same list?
Great question. Flutter has you covered. From the original documentation (flutter.dev/docs/cookbook/design/orientation): OrientationBuilder( builder: (context, orientation) { return GridView.count( // Create a grid with 2 columns in portrait mode, // or 3 columns in landscape mode. crossAxisCount: orientation == Orientation.portrait ? 2 : 3, ); }, );
make a gridview with all elements but the last row. in that last row you will use the widget Row and then you can personalize it (using three containers with different sizes which you can use the "flex" property to do it in the right ratio)
Josh Gamerz that means you need to import the button.dart file. Click on the MyButton that has red underline on it, it should give you an option to import the file
🥷🏽 FOLLOW ME
Patreon: www.patreon.com/mitchkoko/
Instagram: instagram.com/createdbykoko/
Twitter: twitter.com/createdbykoko/
TikTok: www.tiktok.com/@createdbykoko/
I loved your approach of coloring the buttons, here's what I followed:
text color property (will become purple based on setColor's condition):
var textColor = Colors.white;
instance method of the custom button class:
void setColor(String value) {
if (buttonText == 'C') {
buttonColor = Colors.green;
} else if (buttonText == 'DEL') {
buttonColor = Colors.red;
} else if ('%/x-+='.split('').contains(buttonText)) {
buttonColor = Colors.deepPurple;
} else {
buttonColor = Colors.white;
textColor = Colors.deepPurple;
}
}
builder method of the gridview:
(context, index) {
var button = MyButton( buttonText: buttons[index] );
button.setColor(buttons[index]);
return button;
}
At 10:36 you could use '%/*-+='.split('').contains(x)
This is true :) thanks Fabian
I'm New in flutter this is my first week in it
thank you so much
i hope one day i'll be good as you
and Keep posting M right with to to the end
Good luck!
Use required while declaring buttontext to avoid errors
Required this.buttontext
if any one is getting error ..... add this line in starting the video was cut when he add this line import 'package:calculator/buttons.dart'; (replace calculator with your project name)
thanks boss this works perfectly
Nice tutorial bro but I have one question. When you created List those all were strings but if I want to add different types in the same list is it possible to do so?
For Example:
List data = ['clear' , Icons.backspace, '9'];
this results in type icon is not a sub type of string.
I tried this also but can't get the result I wanted:
List data = ['clear' , Icons.backspace, '9'];
How to add integers, string, icon, and many more data types in the same list?
For this just use the ‘var’ type. So instead of ‘List data’, you can do ‘var data’. Inside you can put any type :)
you are the best!!!
Your explanation is very beautiful and clear
Thank you ♥️
im also using vs code but your formatting looks far better than mine......Did you add any plugins or what??
On vscode you can change the theme :)
itemCount: buttons.length, please idnt know why button is showing error.....please help me out
Awesome video!
But how to keep the buttons responsive when rotating the screen?
Great question. Flutter has you covered.
From the original documentation (flutter.dev/docs/cookbook/design/orientation):
OrientationBuilder(
builder: (context, orientation) {
return GridView.count(
// Create a grid with 2 columns in portrait mode,
// or 3 columns in landscape mode.
crossAxisCount: orientation == Orientation.portrait ? 2 : 3,
);
},
);
Subscribed! Keep more coming :)
keep it up bro
Very Helpful
Which software you are using for coding
its called Visual Studio Code
Awesome content man..
Keep posting
How do I add a voice command that will calculate what I say? Please make a viedo.
Interesting! Voice recognition. I will give it a go :)
Cool bro
bro, how can make one button big size of two-button 'ANS ' '=' by replacing it single ' = ' button?
make a gridview with all elements but the last row.
in that last row you will use the widget Row and then you can personalize it (using three containers with different sizes which you can use the "flex" property to do it in the right ratio)
3:13 borderRadius not working in my pc
What does the error say
And i will share your channel also 😊
I am guy who send messages in Instagram 😁
hey dude please help me. I am getting the error: The method 'MyButton' isn't defined for the type '_HomePageState'.
what should i do
Josh Gamerz that means you need to import the button.dart file. Click on the MyButton that has red underline on it, it should give you an option to import the file
@@createdbykoko yes it works now..,...... Thank you very much bro.
You helped me to build my first app.. Thank you very much
We want more videos
download code:?
Hii its free on my github!
@@createdbykoko link
aboout the colors thing, i did the following:
(isOperator function)
dynamic isOperator(String x) {
if ('!%+x/=-'.split("").contains(x)) {
return [Colors.deepPurple, Colors.white];
} else if (x == 'C') {
return [Colors.green, Colors.white];
} else if (x == 'DEL') {
return [Colors.red, Colors.white];
}
// numbers
return [Colors.white, Colors.deepPurple[500]];
}
(how i implemented:)
return MyButton(
buttonText: buttons[index],
color: isOperator(buttons[index])[0],
textColor: isOperator(buttons[index])[1]
);
that's cool.🤍🤍