Hey all i'm getting data from rest api everything is working fine but i want only text data. anyone pls help me

Hello, can you please elaborate more on your requirements?

I’d guess you want to decode the JSON string in the API response to obtain the value (or values?) of the text attribute(/s?), but the complete structure of the response is not visible in the image you posted.

I would reccomend to use code snippets when you need to insert code or data like the above: they are much better than images, i.e they can be copied and pasted in a code editor and experimented with (by the readers).

To insert code and data snippets you should put one ``` line above and one below it, to have it properly formatted and color coded in your message, like the following example snippet showing some JSON encoding and decoding:

// dart:convert provides jsonEncode() and jsonDecode()
import 'dart:convert';

void main() {
  
  // define aMap 
  Map<String, int> aMap = {
    "a": 1,
    "b": 2
  };
  
  // encode aMap as a JSON string:
  String jsonString = jsonEncode(aMap);
  
  // decode back the jsonString as a Map
  Map<String, dynamic> decodedMap = jsonDecode(jsonString);
  
 // test encode -> decode
 print(
   aMap["a"] == decodedMap["a"] &&
   aMap["b"] == decodedMap["b"]
 ); 
  
}

i just want to get text under the description variable.

“description”: “{“blocks”:[{“key”:“1h2pe”,“text”:“Delicious, loquats are very low in calories; provide just 47 cal per 100 g, however, rich in insoluble dietary fiber, pectin. Pectin retains moisture in the colon and thus functions as bulk laxative and by this way, it helps to protect the colon mucous membrane by decreasing exposure time to toxic substances as well as binding to cancer causing chemicals in the colon.Pectin has also been shown to reduce blood cholesterol levels by decreasing its re-absorption in the colon by binding bile acids resulting in its excretion from the body.Loquat fruit is an excellent source of vitamin-A (provides about 1528 IU per 100g), and phenolic flvonoid antioxidants such as chlorogenic acid, neo-chlorogenic acid, hydroxybenzoic acid, feruloylquinic acid, protocatechuic acid, epicatechin, coumaric acids and ferulic acid. Ripen fruits have more chlorogenic acid concentrations.Vitamin A maintains integrity of mucus membranes and skin. Lab studies have shown that consumption of natural fruits rich in vitamin-A and flavonoids helps to protect from lung and oral cavity cancers.Fresh fruit is very rich in potassium and some B-complex vitamins such as folates, vitamin B-6 and niacin and contain small amounts of vitamin-C. Potassium is an important component of cell and body fluids, helps controlling heart rate and blood pressure.It is also a good source of iron, copper, calcium, manganese, and other minerals. Manganese is used by the body as a co-factor for the antioxidant enzyme, superoxide dismutase. Copper is required in the production of red blood cells. Iron is required for as a cofactor in cellular oxidation as well for red blood cell formation.”,“type”:“unstyled”,“depth”:0,“inlineStyleRanges”:[],“entityRanges”:[],“data”:{}}],“entityMap”:{}}”.

Let’s say you have the response’s “description” value in a String description variable, then you could

  1. jsonDecode description, then
  2. access the “blocks” List in the decoded description and
  3. get the first item (or iterate over the list if it has more than one items);
  4. get the value of that item’s “text” property

Check out a basic implementation in this DartPad gist: https://dartpad.dev/671d4d020ec56e19535d72b120459314

To learn more advanced options about the subject have a look at

1 Like

Thank you sooo much for your help can you please tell me how can i use your code. Actually im a beginner soo please help me. Thanks in advance

Please share the full code snippet text that you have used, kindly dont post image

solved thanku for you reply

1 Like

“description”: "{“blocks”:[{“key”:“8sijq”,“text”:“Delicious and crunchy apple is one of the popular fruit that contain an impressive list of essential nutrients, which are required for normal growth and development and overall nutritional well-being.Apples are low in calories; 100 g of fresh fruit slices provide only 50 calories.”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:281,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:281,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:281,“style”:“fontsize-14”},{“offset”:0,“length”:281,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“be1r6”,“text”:“The fruits are however, contain no saturated fats or cholesterol; but rich in dietary fiber, which helps, prevent absorption of dietary LDL cholesterol in the gut.”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:163,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:163,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:163,“style”:“fontsize-14”},{“offset”:0,“length”:163,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“9bdsu”,“text”:“The dietary fibers also help protect the mucous membrane of the colon from exposure to toxic substances by binding to cancer causing chemicals in the colon.Apple fruit contains good quantities of vitamin-C and beta-carotene.”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:224,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:224,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:224,“style”:“fontsize-14”},{“offset”:0,“length”:224,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“ali9n”,“text”:“Vitamin C is a powerful natural antioxidant.”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:44,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:44,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:44,“style”:“fontsize-14”},{“offset”:0,“length”:44,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“batkp”,“text”:“Consumption of foods rich in vitamin C helps body develop resistance against infectious agents and scavenge harmful, pro-inflammatory free radicals from the body.”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:162,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:162,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:162,“style”:“fontsize-14”},{“offset”:0,“length”:162,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“445bu”,“text”:“Apples are rich in antioxidant phyto-nutrients flavonoids and polyphenols.”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:74,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:74,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:74,“style”:“fontsize-14”},{“offset”:0,“length”:74,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“e2080”,“text”:“The total measured anti-oxidant strength (ORAC value) of 100 g apple fruit is 5900 TE.”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:86,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:86,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:86,“style”:“fontsize-14”},{“offset”:0,“length”:86,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“3oa85”,“text”:“The important flavonoids in apples are quercetin, epicatechin, and procyanidin B2.”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:82,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:82,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:82,“style”:“fontsize-14”},{“offset”:0,“length”:82,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“6daev”,“text”:“Apples are also good in tartaric acid that gives tart flavor to them.”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:69,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:69,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:69,“style”:“fontsize-14”},{“offset”:0,“length”:69,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“448sm”,“text”:“These compounds help body protect from deleterious effects of free radicals.”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:76,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:76,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:76,“style”:“fontsize-14”},{“offset”:0,“length”:76,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“5rg3o”,“text”:“In addition, apple fruit is a good source of B-complex vitamins such as riboflavin, thiamin, and pyridoxine (vitamin B-6).”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:122,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:122,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:122,“style”:“fontsize-14”},{“offset”:0,“length”:122,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“cgrv5”,“text”:“Together these vitamins help as co-factors for enzymes in metabolism as well as in various synthetic functions inside the body.”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:127,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:127,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:127,“style”:“fontsize-14”},{“offset”:0,“length”:127,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“aisj2”,“text”:“Apple also contains small amount of minerals like potassium, phosphorus, and calcium.”,“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:85,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:85,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:85,“style”:“fontsize-14”},{“offset”:0,“length”:85,“style”:"fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}},{“key”:“1tmmm”,“text”:"Potassium is an important component of cell and body fluids helps controlling heart rate and blood pressure; thus counters the bad influences of sodium. ",“type”:“unordered-list-item”,“depth”:0,“inlineStyleRanges”:[{“offset”:0,“length”:152,“style”:“color-rgb(33,37,41)”},{“offset”:0,“length”:152,“style”:“bgcolor-rgba(0,0,0,0.05)”},{“offset”:0,“length”:152,“style”:“fontsize-14”},{“offset”:0,“length”:152,“style”:“fontfamily–apple-system, BlinkMacSystemFont, \“Segoe UI\”, Roboto, \“Helvetica Neue\”, Arial, \“Noto Sans\”, sans-serif, \“Apple Color Emoji\”, \“Segoe UI Emoji\”, \“Segoe UI Symbol\”, \“Noto Color Emoji”}],“entityRanges”:[],“data”:{}}],“entityMap”:{}}”

@sakina Hello ma’am. How can i decode only text from this? can you please tell me