This file contains hidden or 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 'dart:math'; | |
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp(const MainApp()); | |
| } | |
| class MainApp extends StatelessWidget { | |
| const MainApp({super.key}); |
This file contains hidden or 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
| {{ if .Values.mysql.backup.enabled }} | |
| apiVersion: batch/v1 | |
| kind: CronJob | |
| metadata: | |
| name: {{ .Release.Name }}-mysql-backup | |
| spec: | |
| schedule: {{ .Values.mysql.backup.schedule | quote }} | |
| jobTemplate: | |
| spec: | |
| ttlSecondsAfterFinished: {{ .Values.mysql.backup.ttlSecondsAfterFinished }} |
This file contains hidden or 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 'dart:async'; | |
| final transformer = StreamTransformer<int, int>.fromHandlers( | |
| handleData: (data, sink) { | |
| print('transformed'); | |
| sink.add(data * 2); // For every data event, we double the value. | |
| }, | |
| handleError: (error, stacktrace, sink) { | |
| sink.addError('An error occurred: $error'); // We transform any error. | |
| }, |
This file contains hidden or 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
| sealed class Shape {} | |
| class Circle extends Shape { | |
| Circle(this.radius); | |
| final double radius; | |
| } | |
| class Rectangle extends Shape { | |
| Rectangle(this.width, this.height); |
This file contains hidden or 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
| sealed class Shape { | |
| double calcSquare(); | |
| } | |
| class Circle extends Shape { | |
| Circle(this.radius); | |
| final double radius; | |
| @override |
This file contains hidden or 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
| abstract interface class Account { | |
| double get balance; | |
| } | |
| class SavingsAccount implements AccountType { | |
| double balance; | |
| SavingsAccount(this.balance); | |
| } |
This file contains hidden or 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
| class Bird { | |
| void fly() { | |
| print('The bird is flying.'); | |
| } | |
| } | |
| class Ostrich extends Bird { | |
| @override | |
| void fly() { | |
| throw UnsupportedError('Ostriches cannot fly.'); |
This file contains hidden or 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() { | |
| // create final variables that reference canonical object | |
| final a = const A('A'); | |
| final b = const A('A'); | |
| // check if both a and b reference the same object | |
| print(identical(a, b)); // True | |
| // strings are const by default | |
| // note, that str reference canonical object of type String |
This file contains hidden or 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 'dart:async'; | |
| import 'package:crypto/crypto.dart'; | |
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp(const MainApp()); | |
| } | |
| class MainApp extends StatefulWidget { |
This file contains hidden or 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:shared_preferences/shared_preferences.dart'; | |
| /// {@template preferences_dao} | |
| /// Class that provides seamless access to the shared preferences. | |
| /// | |
| /// Inspired by https://pub.dev/packages/typed_preferences | |
| /// {@endtemplate} | |
| abstract base class PreferencesDao { | |
| final SharedPreferences _sharedPreferences; |