H
H
Helcurt2021-10-18 14:17:05
Dart
Helcurt, 2021-10-18 14:17:05

When getting data from the session and outputting text, type 'Future' is not a subtype of type 'String' in type cast?

Getting data from the session

String token = FlutterSession().get("token") as String;

and output the variable
Text(token, style: const TextStyle(
          color: Colors.blue,
          fontSize: 30,
          fontWeight: FontWeight.bold,
        ),),


Result:
616d57abe8528995326854.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Aleksandrovich, 2021-10-18
@RomReed

String? token = FlutterSession().get("token");
Text(token??'empty token', style: const TextStyle(
color: Colors.blue,
fontSize: 30,
fontWeight: FontWeight.bold,
),),
try this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question