Skip to content

Instantly share code, notes, and snippets.

@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;
class VideoControlOverlay extends ViewModelWidget<StackedVideoViewModel> {
@override
Widget build(BuildContext context, StackedVideoViewModel model) {
return Container(
height: model.thumbnailHeight,
width: model.thumbnailWidth,
child: Stack(
children: <Widget>[
AnimatedSwitcher(
duration: Duration(milliseconds: 50),
@jtmuller5
jtmuller5 / video_thumbnail.dart
Created January 12, 2021 17:19
Reusable video thumbnail ViewModelWidget
class VideoThumbnail extends ViewModelWidget<StackedVideoViewModel> {
@override
Widget build(BuildContext context, StackedVideoViewModel model) {
return Builder(
builder: (context) {
// If we want to show the full video, we need to scale it to fit the longest side
if (model.showFull) {
bool wideVideo =
model.videoPlayerController.value.size.width >
class StackedVideoView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ViewModelBuilder<StackedVideoViewModel>.reactive(
viewModelBuilder: () => StackedVideoViewModel(),
onModelReady: (model) {
model.initialize(
'https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4');
},
builder: (context, model, child) {