This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
//example1 simple use generic class | |
print('example 1'); | |
GenericExample<String> example1 = GenericExample('SomeString'); | |
GenericExample<int> example2 = GenericExample(123); | |
print(example1.genericField); | |
print(example2.genericField); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum MyEnum { one, two, three } | |
void main() { | |
print(MyEnum.one); | |
print(MyEnum.one.name); // one | |
final map = MyEnum.values.asNameMap(); | |
print(map); | |
print(MyEnum.values.byName('two')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ignore_for_file: avoid_print | |
/// Проблематика: | |
/// Как правильно объявлять переменные в абстрактных класах, чтоб в классах которые их имплементируют, эти переменные можно | |
/// было переопределять как immutable так и muttable (с ключевым словом final так и без) | |
///Вариант первый. использвать late final | |
///В таком случае в классе который имплементится от этого абстрактного класса это поле можно использовать без ключевого слово final | |
///Если в реализации нужно использвать immutable переменную - нужно реализовывать еще и сеттер. | |
///Так же в документации рекомендуется не использовать late final (https://dart.dev/guides/language/effective-dart/design#avoid-public-late-final-fields-without-initializers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//сортировка вставками | |
void main() { | |
final array = <int>[5, 2, 6, 14, 87, 11, 9, 3, 76]; | |
print(array); | |
sort(array); | |
print(array); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() async { | |
// final bool1 = await getSomeFuture1(); | |
// final bool2 = await getSomeFuture2(); | |
final bool3 = await getSomeFuture3(); | |
// print(bool1); | |
// print(bool2); | |
print(bool3); | |
} | |
Future<bool> getSomeFuture3() async { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter/gestures.dart'; | |
void main() { | |
runApp(const FlutterPresentation()); | |
} | |
class _FlutterPresentationState extends State<FlutterPresentation> { |