faithoflifedev / yt Goto Github PK
View Code? Open in Web Editor NEWMultiple YouTube APIs in one Dart library
License: MIT License
Multiple YouTube APIs in one Dart library
License: MIT License
after installing CLI on macos, it's not finding it when I run the command yt --help.
here is my source code
import "dart:io";
import "package:flutter/material.dart";
import "package:image_picker/image_picker.dart";
import "package:yt/yt.dart";
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Flutter Demo",
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: "Flutter Demo Home Page"),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: OutlinedButton(
onPressed: () async {
XFile? file = await ImagePicker().pickVideo(source: ImageSource.gallery);
final yt = Yt.withKey("--- My API key ---");
final body = <String, dynamic>{
"snippet": {
"title": "TEST title",
"description": "Test Description",
"tags": [
"tag1",
"tag2"
],
"categoryId": "22"
},
"status": {
"privacyStatus": "private",
"embeddable": true,
"license": "youtube"
}
};
final vfile = File(file!.path);
final videoItem = await yt.videos.insert(body: body, videoFile: vfile);
print(videoItem);
},
child: const Text("Upload..."),
),
),
);
}
}
The above code was written as an exercise.
However, the following error occurs:
E/flutter ( 8711): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 8711): #0 Yt.videos (package:yt/src/yt_base.dart:43:31)
E/flutter ( 8711): #1 _MyHomePageState.build.<anonymous closure> (package:yt_exam/main.dart:72:40)
E/flutter ( 8711): <asynchronous suspension>
E/flutter ( 8711):
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.