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
// TODO: Implement the [isSubtype] function. Must be a general solution, no hardcoding stuff! | |
// Check if [A] is a subtype of [B], according to https://dart.dev/resources/glossary#subtype | |
// For example: | |
// - int is a subtype of num | |
// - List<int> is a subtype of List<num> | |
// - Labrador is a subtype of Animal | |
bool isSubtype<A, B>() { | |
// TODO: Implement this! |
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() { | |
bench('version 1', () { | |
get1(); | |
}); | |
bench('version 2', () { | |
get2(); | |
}); | |
} | |
Map<String, dynamic> get1() { |
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/rendering.dart'; | |
import 'package:flutter/widgets.dart'; | |
typedef SelectionTransform = String Function(Iterable<String>); | |
/// A widget that transforms the text selection when copied. | |
/// | |
/// This uses the [SelectionContainer] with a custom [SelectionContainerDelegate] to override the | |
/// [getSelectedContent] method with a custom implementation. | |
/// |
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_riverpod/flutter_riverpod.dart'; | |
/* | |
============ | |
EXAMPLE PART | |
============ | |
*/ | |
// case 1: basic provider |
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:dart_json_mapper/dart_json_mapper.dart'; | |
import 'main.mapper.g.dart'; | |
@jsonSerializable | |
class Car { | |
String model; | |
int? miles; | |
List<String>? passengers; | |
Car(this.model, this.miles, this.passengers); |
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'; | |
class NestedWillPopScope extends StatefulWidget { | |
const NestedWillPopScope({ | |
Key? key, | |
required this.child, | |
required this.onWillPop, | |
}) : super(key: key); | |
final Widget child; |
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
{"networkStateVersions":{"MVG_RAD":1488789},"fullDataSet":{"MVG_RAD":true},"onlyNearbyData":false,"failingProviderIds":[],"addedBikes":[{"id":"96048","created":null,"updated":1522583999000,"bikeNumber":96048,"latitude":0.0,"longitude":0.0,"currentStationID":null,"bikeState":"FREE","bikeType":"STANDARD","positionType":"IN_OPERATING_AREA","localized":false,"district":null},{"id":"96101","created":1522583997000,"updated":1522583997000,"bikeNumber":96101,"latitude":48.150386810302734,"longitude":11.544791221618652,"currentStationID":"dead08f4081592823ada3017f622c695","bikeState":"FREE","bikeType":"STANDARD","positionType":"STATION","localized":true,"district":"Neuhausen-Nymphenburg"},{"id":"96102","created":1522583997000,"updated":1522583997000,"bikeNumber":96102,"latitude":48.139400482177734,"longitude":11.588881492614746,"currentStationID":"98ee05824cb579da3539acb38e63d81c","bikeState":"FREE","bikeType":"STANDARD","positionType":"STATION","localized":true,"district":"Altstadt-Lehel"},{"id":"96103","created":152 |