Все больше и больше появляется статей по поводу этого инструмента и, если вы еще не слышали о нем, то вам стоит уделить ему хотя бы немного вашего времени. Думаю, за небольшое время мы сможем познакомиться с плюсами и минусами его использования, а также рассмотреть примеры кода, что даст понимание, как и когда стоит переходить на Flutter.
8. Dart 2
You can control the flow of your Dart code using any of the following:
● if and else
● for loops
● while and do-while loops
● break and continue
● switch and case
● assert
You can also affect the control flow using try-catch and throw, as explained in Exceptions.
8
9. Dart 2
Asynchrony support:
Future<int> lookUpVersion() async {
// Do something to get version
await for (varOrType identifier in expression)
{// Executes each time the stream emits a value.}
}
var version = await lookUpVersion();
print(version);
9
lookUpVersion()
.then( (version){
print(version); } )
.catchError( (error){//handle
error} )
11. API 16API 26
Flutter disadvantages
- May not support necessary UI
Element (Search view...)
- Uses more resources of the
device (over 3x heavier on CPU,
and uses 3x much memory than
native iOS app)
- Simple multithreading
- May not have some functionality
at all
- Some plugins may not support
one of platforms
- Not support vector images
- Supports only 15 locales
- Platform dependent
disadvantages (fonts, multilang)
- Size of the final app
14. Flutter localizations
(at the end of 2017 supports 15 languages)
There are 3 ways:
1. Localizations.of<MaterialLocalizations>(context, MaterialLocalizations);
2. notOnlineMessage(String userName, String userGender) =>
Intl.gender(
userGender,
male: '$userName is unavailable because he is not online.',
female: '$userName is unavailable because she is not online.',
other: '$userName is unavailable because they are not online',
name: "notOnlineMessage",
args: [userName, userGender],
desc: "The user is not available to hangout.",
examples: const {{'userGender': 'male', 'userName': 'Fred'},
{'userGender': 'female', 'userName' : 'Alice'}});
supports plurals, biditext, and autoextract
3. Your variant (probably json map inside app)
14