use of HexEncoder class from flutter

8,222

This should do what you want:

import 'package:convert/convert.dart';

List<int> value = [253, 165, 6, 147, 164, 226, 79, 177, 175, 207, 198, 235, 7, 100, 120, 37];
var result = hex.encode(value);

This code

HexEncoder _hexEncoder;

just declares a variable _hexEncoder but doesn't initialize it with an encoder instance or any other value and therefor is null.

Share:
8,222
Lu Chinke
Author by

Lu Chinke

Developers, developers, developers, developers, developers, developers. Developers, developers, developers, developers, developers, developers, developers, developers. Yes!

Updated on December 05, 2022

Comments

  • Lu Chinke
    Lu Chinke over 1 year

    I am trying to use the class HexEncoder from https://docs.flutter.io/flutter/convert/HexEncoder-class.html and i can't make it work. Actually i am doing this to convert a list of bytes to a string:

    import 'dart:convert';
    import 'package:convert/convert.dart';
    
    HexEncoder _hexEncoder;
    List<int> value = [253, 165, 6, 147, 164, 226, 79, 177, 175, 207, 198, 235, 7, 100, 120, 37]
    _hexEncoder.convert(value);
    

    but throws me the error:

     The method 'convert' was called on null
    

    Sorry for my poor knowledge of dart/flutter. I know i amb calling a null object, i just need to know the way to use this class. Thank you so much !

  • amorenew
    amorenew about 4 years
  • Günter Zöchbauer
    Günter Zöchbauer about 4 years
    I do not understand your question. What fo you mean with "updated"?
  • amorenew
    amorenew about 4 years
    Sorry it is a misunderstanding the parent class is HexCodec it is not an issue