#flutter
Let's study #Dart.
final, const & late in 3+ steps.
🧵👇
1/1 What is the difference between final and const?
A constant variable must be initialized at the time of declaration. It's a compile-time constant. A final variable can be initialized later, but only once when the first time it’s used.
1/2 void main() {
final int x;
const int y = 1;
x = 8; // ok
y = 2; // error: Constant variables can't be assigned a value.
x = 9; // error: The final variable 'a' can only be set once.
}
2/1 Const is used to create constant values and to declare constructors by which immutable values are created. This allows any variable to have an immutable value.
2/2 var one = const [];
one = const [1, 2, 3]; // ok
one[0] = 4; //Unsupported operation: Cannot modify an unmodifiable list
final two = const [];
two = const [10, 3, 23]; // error
const three = [];
three = const [10, 3, 23]; // error
3/1 The late was added in Dart 2.12 and has now two uses: 1. To declare a variable that doesn't store a null value, which is initialized after it is declared; 2. For lazy variable initialization.
3/2 What is the difference between final and late?
Modifier final cannot be declared at the top level of the code. At the same time, variables declared with one of these modifiers must be initialized before they are used. Otherwise, an exception will be thrown.
3/3 late String lateName;
// final int finalName; // error
void main() {
final int finalName; // ok
// print(lateName); //error
// LateInitializationError: Field 'lateName' has not been initialized
lateName = '#Flutter';
print(lateName); // ok
}
Did you really read to the end and not fall asleep?
Don't follow me. You can get smart. twitter.com/intent/follow?…
#Flutter#Dart#CSS
CSS vs Flutter.
How to embed CSS examples in the text widget.
My success story.
Of course, you can find 15 awesome examples below.
🧵👇
1 #Flutter#Dart#CSS
When I found an example, I thought, why not?
Shadows in CSS has this syntax:
// text-shadow: [horizontal offset] [vertical offset] [blur radius] [color];
// text-shadow: 0 2px 1px #747474,
// rgbo: 0px -4px 10px rgba(255,255,255,0.3);
2 #Flutter#Dart#CSS
Each shadow in the Text widget has 5 lines of code.
Shadow(
color: Color(0xFFFFFFFF),
offset: Offset(1.0, 1.0),
blurRadius: 1.0,
),
It's all good, but I broke my head when I found the example with 26 shadows.
WTF... 🤯🤯🤯
#Flutter#Dart#CSS
CSS vs Flutter.
Flutter the containers with shadows.
How to create BoxShadow with CSS box-shadow?
21 amazing containers with CSS box-shadow in Flutter for the next app.
🧵👇
Let's study #Flutter.
How to remember new buttons in Flutter?
Old RaisedButton >>> ElevatedButton
Old FlatButton >>> TextButton
Old OutlinedButton >>> OutlinedButton
Three examples below & in DartPad🧵👇