Skip to content

Instantly share code, notes, and snippets.

@injectable
class MediaService {
final picker = ImagePicker();
/// Select an image from the user's device
Future<File> selectImage({ImageSource source = ImageSource.gallery}) async {
final pickedFile = await picker.getImage(source: source);
if(pickedFile!= null) {
return File(pickedFile.path);
Future<void> incrementCounter(String key) async {
AtKey atKey = AtKey();
atKey.key = key;
/// Share with the other sign
if(shareWith) {
atKey.sharedWith = AtConstants().atMap[atProtocolService.currentAtSign];
}
counter++;
Future<void> initialize() async {
String privateKey = await atProtocolService.getPrivateKey(atProtocolService.currentAtSign);
try {
atProtocolService.atClientImpl.startMonitor(privateKey, printResult);
} on ConnectionInvalidException catch (e){
print('connection error: '+ e.toString());
}
}
Future<void> printResult(String val) async {
@jtmuller5
jtmuller5 / onboard.dart
Created March 24, 2021 19:56
Create an AtClient
/// Create an AtClient (AtClientImpl) to communicate with the person's
/// secondary server
Future<bool> onboard({String atsign}) async {
atClientImpl = null;
atClientService = AtClientService();
Directory downloadDirectory;
/// The directory where keys will be stored
if (Platform.isIOS) {
downloadDirectory =
import 'dart:io';
import 'package:at_client_mobile/at_client_mobile.dart';
import 'package:at_commons/at_commons.dart';
import 'package:at_list/app/at_constants.dart';
import 'package:at_list/app/router.gr.dart';
import 'package:auto_route/auto_route.dart';
import 'package:flutter/cupertino.dart';
import 'package:injectable/injectable.dart';
import 'package:path_provider/path_provider.dart' as path_provider;
import 'package:image/image.dart';
import 'package:tflite_flutter/tflite_flutter.dart';
import 'package:tflite_flutter_helper/src/image/tensor_image.dart';
import 'package:tflite_flutter_helper/src/tensorbuffer/tensorbuffer.dart';
import 'dart:typed_data';
/// Implements some stateless image conversion methods.
///
/// This class is an internal helper.
class ImageConversion {
class VideoTimeElapsed extends ViewModelWidget<StackedVideoViewModel> {
@override
Widget build(BuildContext context, StackedVideoViewModel model) {
return Container(
padding: EdgeInsets.only(bottom: 8, left: 8),
height: model.thumbnailHeight,
width: model.thumbnailWidth,
child: Align(
alignment: Alignment.bottomLeft,
child: Container(
class VideoTimeRemaining extends ViewModelWidget<StackedVideoViewModel> {
@override
Widget build(BuildContext context, StackedVideoViewModel model) {
return Container(
padding: EdgeInsets.only(bottom: 8, right: 8),
height: model.thumbnailHeight,
width: model.thumbnailWidth,
child: Align(
alignment: Alignment.bottomRight,
child: Container(
/// (1) Use the WidgetsBindingObserver to get the VideoThumbnail's size
/// after it is laid out
class VideoThumbnail extends ViewModelWidget<StackedVideoViewModel> with WidgetsBindingObserver{
@override
Widget build(BuildContext context, StackedVideoViewModel model) {
/// (3) Get the size of the widget after it is rendered on screen
WidgetsBinding.instance
.addPostFrameCallback((_) {
class StackedVideoViewModel extends BaseViewModel {
// Input Properties
VideoPlayerController videoPlayerController;
bool showFull;
double x; // X alignment of FittedBox
double y; // Y alignment of FittedBox
// Local Properties
bool gotThumbnailSize = false;