<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcGISCredential.fromJson() throws exception &amp;quot;Null check operator used on a null value&amp;quot; in Flutter Maps SDK Questions</title>
    <link>https://community.esri.com/t5/flutter-maps-sdk-questions/arcgiscredential-fromjson-throws-exception-quot/m-p/1634380#M130</link>
    <description>&lt;P&gt;&lt;SPAN&gt;You don't need to use WebView to login. You can do that directly through the Flutter Maps SDK using TokenCredential with this approach:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;final credential = await TokenCredential.create(
  uri: Uri.parse(portalURL),
  username: username,
  password: password,
);&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Add the credential to the credential store:&amp;nbsp;&lt;/STRONG&gt;This is where you were getting the null error. Use the TokenCredential directly:&lt;/P&gt;&lt;PRE&gt;ArcGISEnvironment.authenticationManager.arcGISCredentialStore.addForUri(
  credential: credential,  // Use the TokenCredential, not a JSON map
  uri: Uri.parse(portalURL),
);&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Create and load the authenticated portal:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;final portal = Portal.arcGISOnline(
  connection: PortalConnection.authenticated,
);
await portal.load();&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Get the license info for offline functionality:&lt;/STRONG&gt; This is what you need for offline Portal APIs:&lt;/P&gt;&lt;PRE&gt;final licenseInfo = await portal.fetchLicenseInfo();
print('License: ${licenseInfo.toJson()}');

&lt;BR /&gt;// You'd get something like: {licenseString: LICENSE_KEY}&lt;/PRE&gt;&lt;P&gt;This should eliminate your null pointer exception and get you the offline licensing you're looking for.&lt;/P&gt;&lt;P&gt;Checkout this sample for a full example:&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-maps-sdk-flutter-samples/tree/main/lib/samples/authenticate_with_token" target="_blank"&gt;https://github.com/Esri/arcgis-maps-sdk-flutter-samples/tree/main/lib/samples/authenticate_with_token&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Let me know if you have any questions!&lt;/P&gt;</description>
    <pubDate>Sat, 19 Jul 2025 02:07:51 GMT</pubDate>
    <dc:creator>kossiyovo</dc:creator>
    <dc:date>2025-07-19T02:07:51Z</dc:date>
    <item>
      <title>ArcGISCredential.fromJson() throws exception "Null check operator used on a null value"</title>
      <link>https://community.esri.com/t5/flutter-maps-sdk-questions/arcgiscredential-fromjson-throws-exception-quot/m-p/1633393#M128</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;I am trying to add the credentials via&amp;nbsp;&lt;SPAN&gt;ArcGISEnvironment&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;authenticationManager&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;arcGISCredentialStore&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;addForUri()&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;I have logged into the AGOL via WebView and after successful login. I am trying to add the credentials. I tried following,&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;LI-CODE lang="c"&gt;      final credentialMap = {
        "token": token,
        "userId": username,
        "expiration": expireTime.toIso8601String(),
      };

      final tokenCredential = ArcGISCredential.fromJson(credentialMap);

      // Add credential to the store
     ArcGISEnvironment.authenticationManager.arcGISCredentialStore.addForUri(
        credential: tokenCredential,
        uri: Uri.parse(portalURL),
      );

      final portal = Portal.arcGISOnline(
        connection: PortalConnection.authenticated,
      );
      await portal.load();&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I checked every thing none of value is null in credentialMap, but I am still getting an exception line no. 7 -&amp;nbsp;"Null check operator used on a null value".&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;Not sure what I am missing here. Any help would be appreciated.&lt;BR /&gt;&lt;BR /&gt;fyi, I successfully login and have the token and other user details, its just I want to use Portal APIs exposed by SDK. I am looking to get the license info so that app could work offline and use portal APIs. It appears there is no url to get the license via http call.&lt;/DIV&gt;</description>
      <pubDate>Wed, 16 Jul 2025 04:45:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/flutter-maps-sdk-questions/arcgiscredential-fromjson-throws-exception-quot/m-p/1633393#M128</guid>
      <dc:creator>AM01</dc:creator>
      <dc:date>2025-07-16T04:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGISCredential.fromJson() throws exception "Null check operator used on a null value"</title>
      <link>https://community.esri.com/t5/flutter-maps-sdk-questions/arcgiscredential-fromjson-throws-exception-quot/m-p/1634380#M130</link>
      <description>&lt;P&gt;&lt;SPAN&gt;You don't need to use WebView to login. You can do that directly through the Flutter Maps SDK using TokenCredential with this approach:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;final credential = await TokenCredential.create(
  uri: Uri.parse(portalURL),
  username: username,
  password: password,
);&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Add the credential to the credential store:&amp;nbsp;&lt;/STRONG&gt;This is where you were getting the null error. Use the TokenCredential directly:&lt;/P&gt;&lt;PRE&gt;ArcGISEnvironment.authenticationManager.arcGISCredentialStore.addForUri(
  credential: credential,  // Use the TokenCredential, not a JSON map
  uri: Uri.parse(portalURL),
);&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Create and load the authenticated portal:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;final portal = Portal.arcGISOnline(
  connection: PortalConnection.authenticated,
);
await portal.load();&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Get the license info for offline functionality:&lt;/STRONG&gt; This is what you need for offline Portal APIs:&lt;/P&gt;&lt;PRE&gt;final licenseInfo = await portal.fetchLicenseInfo();
print('License: ${licenseInfo.toJson()}');

&lt;BR /&gt;// You'd get something like: {licenseString: LICENSE_KEY}&lt;/PRE&gt;&lt;P&gt;This should eliminate your null pointer exception and get you the offline licensing you're looking for.&lt;/P&gt;&lt;P&gt;Checkout this sample for a full example:&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-maps-sdk-flutter-samples/tree/main/lib/samples/authenticate_with_token" target="_blank"&gt;https://github.com/Esri/arcgis-maps-sdk-flutter-samples/tree/main/lib/samples/authenticate_with_token&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Let me know if you have any questions!&lt;/P&gt;</description>
      <pubDate>Sat, 19 Jul 2025 02:07:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/flutter-maps-sdk-questions/arcgiscredential-fromjson-throws-exception-quot/m-p/1634380#M130</guid>
      <dc:creator>kossiyovo</dc:creator>
      <dc:date>2025-07-19T02:07:51Z</dc:date>
    </item>
  </channel>
</rss>

