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 'dart:collection'; | |
import 'package:meta/meta.dart'; | |
/// A listener that can be added to a [EventEmitter] using | |
/// [EventEmitter.on] or [EventEmitter.addListener]. | |
/// | |
/// This callback gets invoked once we call [EventEmitter.emit]. | |
typedef Listener<T> = void Function(T data); |
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:rxdart/rxdart.dart'; | |
class StreamDebounce { | |
final Function func; | |
final Duration interval; | |
final subject = PublishSubject<List<dynamic>>(); | |
StreamSubscription subscriber; |
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'; | |
/// Signature for for the static method [Function.apply]. | |
typedef ApplicableFunction = void Function( | |
List<dynamic> positionalArguments, { | |
Map<Symbol, dynamic> namedArguments, | |
}); | |
/// Useful rate limiter extensions for [Function] class. | |
extension RateLimit on Function { |
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 'dart:math' as math; | |
/// Creates a debounced function that delays invoking `func` until after `wait` | |
/// milliseconds have elapsed since the last time the debounced function was | |
/// invoked, or until the next browser frame is drawn. The debounced function | |
/// comes with a `cancel` method to cancel delayed `func` invocations and a | |
/// `flush` method to immediately invoke them. Provide `options` to indicate | |
/// whether `func` should be invoked on the leading and/or trailing edge of the | |
/// `wait` timeout. The `func` is invoked with the last arguments provided to the |
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:convert'; | |
import 'package:dio/dio.dart'; | |
import 'package:mockito/mockito.dart'; | |
import 'package:stream_feed_dart/src/core/api/batch_api_impl.dart'; | |
import 'package:stream_feed_dart/src/core/http/http_client.dart'; | |
import 'package:stream_feed_dart/src/core/http/token.dart'; | |
import 'package:stream_feed_dart/src/core/models/activity.dart'; | |
import 'package:stream_feed_dart/src/core/models/feed_id.dart'; | |
import 'package:stream_feed_dart/src/core/util/routes.dart'; |
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
extension StringX on String { | |
/// Creates a `Duration` object from an ISO8601 formatted string. | |
/// | |
/// This method parses out a subset of the ISO8601 duration format. As years | |
/// and months are not of a set length this method does not support that. We | |
/// are then left with support for weeks, days, hours, minutes and seconds. | |
Duration get toDuration { | |
if (!RegExp( | |
r"^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$") | |
.hasMatch(this)) { |
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:collection'; | |
import 'dart:convert'; | |
void main() { | |
final data = json.decode( | |
"[{\"videoId\":1,\"videoName\":\"Test Video 1\",\"duration\":300,\"createdTime\":\"1969-07-20 20:18:04Z\",\"isWatch\":1},{\"videoId\":1,\"videoName\":\"Test Video 1\",\"duration\":300,\"createdTime\":\"1969-07-20 20:18:04Z\",\"isWatch\":50},{\"videoId\":1,\"videoName\":\"Test Video 1\",\"duration\":300,\"createdTime\":\"1969-07-21 20:18:04Z\",\"isWatch\":20}]"); | |
final map = HashMap<String, int>(); | |
for (var value in (data as List)) { | |
if (map[value['createdTime']] == null) { |
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
@immutable | |
class ApiException implements Exception { | |
final String _message; | |
final String _prefix; | |
String get message => _message; | |
const ApiException([this._message, this._prefix]); | |
String toString() => "$_prefix$_message"; |
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() async { | |
var container = await AppComponent.create(ServicesModule(), ViewModelModule()); | |
runApp(container.app); | |
} | |
@provide | |
class MyApp extends StatelessWidget { | |
final Router _router; | |
MyApp(this._router); |
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 MovieModel extends Model { | |
MovieRepository _movieRepository; | |
ApiResponse<List<Movie>> _movieList; | |
ApiResponse<List<Movie>> get movieList => _movieList; | |
MovieModel() { | |
_movieList = ApiResponse(); | |
_movieRepository = MovieRepository(); |