Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3640

Error on device: Null check operator used on a null value

$
0
0

My code in homepage.dart

// ignore_for_file: sized_box_for_whitespace, prefer_const_constructors, unused_element, avoid_unnecessary_containersimport 'package:cached_network_image/cached_network_image.dart';import 'package:flutter/material.dart';import 'package:friendlycourse/UI/modals/channel_info.dart';import 'package:friendlycourse/UI/net/services.dart';import 'package:friendlycourse/UI/screens/drawer.dart';class MyHomePage extends StatefulWidget {  const MyHomePage({Key? key, required this.title}) : super(key: key);  final String title;  @override  State<MyHomePage> createState() => _MyHomePageState();}class _MyHomePageState extends State<MyHomePage> {  // get searchBar => null;  ChannelInfo? _channelInfo;  Item? _item;  // late bool _loading;  @override  void initState() {    super.initState();    // _loading = true;    _getChannelInfo();  }  _getChannelInfo() async {    _channelInfo = await Services.getChannelInfo();    _item = _channelInfo!.items[0];    // setState(() {    //   _loading = false;    // });  }  @override  Widget build(BuildContext context) {    return Scaffold(      drawer: MyDrawer(),      appBar: AppBar(        title: Text(widget.title),        // actions: <Widget>[        //   IconButton(icon: Icon(Icons.search),onPressed: (){},)        // ],      ),      body: Container(        child: Column(          children: [            _buildInfoView(),          ],        ),      ),    );  }  _buildInfoView() {    return Container(        child: Card(      child: Row(        children: [          CircleAvatar(            backgroundImage: CachedNetworkImageProvider(              _item!.snippet.thumbnails.medium.url,            ),          ),          SizedBox(            width: 20,          ),          Text(            _item!.snippet.title,            style: TextStyle(              fontSize: 20,              fontWeight: FontWeight.w400,            ),          )        ],      ),    ));  }} My code in services.dart    import 'dart:io';    import 'package:friendlycourse/UI/modals/channel_info.dart';    import 'package:friendlycourse/UI/net/constants.dart';    import 'package:http/http.dart' as http;    import 'package:http/http.dart';    class Services {      static const channelId = 'UCBwmMxybNva6P_5VmxjzwqA';      static const _baseUrl = 'youtube.googleapis.com';      static Future<ChannelInfo> getChannelInfo() async {        Map<String, String> parameters = {'part': 'snippet','id': channelId,'key': Constant.apikey,        };        Map<String, String> headers = {          HttpHeaders.contentTypeHeader: 'application/json'        };        Uri uri = Uri.https(_baseUrl, 'youtube/v3/search', parameters);        Response response = await http.get(uri, headers: headers);        print(response.body);        ChannelInfo channelInfo = channelInfoFromJson(response.body);        return channelInfo;**
  1. emphasized text

** I am trying to make video player flutter app using youtube api v3 and there is no error in the code but after running it my device gives me error: "null check operator used a null value" i don't know how to solve the issue please help me. I am new to flutter.}}


Viewing all articles
Browse latest Browse all 3640

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>