Skip to content

Instantly share code, notes, and snippets.

View responsive_interactive_viewer.dart
GestureDetector(
onTap: () {
model.setInteraction(false);
},
behavior: HitTestBehavior.deferToChild,
child: InteractiveViewer(
panEnabled: false,
boundaryMargin: EdgeInsets.all(80),
onInteractionStart: (details) {
model.setInteraction(true);
View body_painter.dart
class BodyPainter extends CustomPainter {
final BuildContext context;
final BodySelectorViewModel model;
BodyPainter({
required this.context,
required this.model,
});
@override
View body_canvas.dart
class BodyCanvas extends ViewModelWidget<BodySelectorViewModel> {
@override
Widget build(BuildContext context, BodySelectorViewModel model) {
return CanvasTouchDetector(
builder: (context) => CustomPaint(
painter: BodyPainter(
context: context,
model: model,
),
),
View xml_parser.dart
Future<void> loadSvgImage({required bool back, required String svgImage}) async {
String generalString = await rootBundle.loadString(svgImage);
XmlDocument document = XmlDocument.parse(generalString);
final paths = document.findAllElements('path');
paths.forEach((element) {
String partName = element.getAttribute('id').toString();
View speech_service_continuous.dart
import 'package:injectable/injectable.dart';
import 'package:porcupine/porcupine.dart';
import 'package:porcupine/porcupine_error.dart';
import 'package:porcupine/porcupine_manager.dart';
import 'package:speech_to_text/speech_recognition_result.dart';
import 'package:speech_to_text/speech_to_text.dart' as stt;
import 'package:stacked/stacked.dart';
@singleton
class SpeechService with ReactiveServiceMixin {
View porcupine_manager.dart
PorcupineManager porcupineManager;
/// Create an instance of your porcupineManager which will listen for the given wake words
/// Must call start on the manager to actually start listening
void createPorcupineManager() async {
try{
porcupineManager = await PorcupineManager.fromKeywords(
Porcupine.BUILT_IN_KEYWORDS,
wakeWordCallback);
} on PvError catch (err) {
View single_command_view_model.dart
import 'package:desk_monkey/services/services.dart';
import 'package:stacked/stacked.dart';
class SingleCommandViewModel extends BaseViewModel{
String recognizedWords = '';
void initialize(){
}
View single_command_view.dart
import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart';
import 'single_command_view_model.dart';
class SingleCommandView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ViewModelBuilder<SingleCommandViewModel>.reactive(
viewModelBuilder: () => SingleCommandViewModel(),
View speech_service.dart
import 'package:injectable/injectable.dart';
import 'package:speech_to_text/speech_recognition_result.dart';
import 'package:speech_to_text/speech_to_text.dart' as stt;
@singleton
class SpeechService{
bool speechAvailable = false;
stt.SpeechToText speech = stt.SpeechToText();
View at_read_image.dart
Uint8List pic;
Future<void> readPic() async {
AtKey atKey = AtKey();
atKey.key = 'pic';
// Get keys shared by the other sign
if (!mine) {
atKey.sharedBy = AtConstants().atMap[atProtocolService.currentAtSign];
}