i trying to translate a string and show it to my screen but when i try to check the text on print it say Instance of Future<Translation>
this is my code when i try to use then(print)
final finalLastSeen = translator
.translate(timeago.format(userLastSeen), from: 'en', to: 'id')
.then(print);
it show the string that i want. but when i make this
final finalLastSeen = translator.translate(timeago.format(userLastSeen),
from: 'en', to: 'id');
print(finalLastSeen);
it will show the Future error
this is my whole FutureBuilder Code
return FutureBuilder(
future: users.doc(product.userId).get(),
builder:
(BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot) {
if (snapshot.hasError) {
return const Text("Something went wrong");
}
if (snapshot.hasData && !snapshot.data!.exists) {
return const Text("Document does not exist");
}
if (snapshot.connectionState == ConnectionState.done) {
Map<String, dynamic> data =
snapshot.data!.data() as Map<String, dynamic>;
_sellerImageurl = '${data['imageUrl']}';
_sellerName = '${data['name']}';
_sellerJoinedDate = '${data['createdAt']}';
_sellerCity = '${data['location']}';
_sellerStatus = '${data['status']}';
_sellerLastSeen = '${data['lastSeen']}';
}
final DateTime lastSeen = DateTime.parse(_sellerLastSeen);
final Duration _sellerTimePassed = time.difference(lastSeen);
final userLastSeen = DateTime.now().subtract(_sellerTimePassed);
final _userOffline = '';
print(timeago.format(userLastSeen));
final finalLastSeen = await translator.translate(timeago.format(userLastSeen),
from: 'en', to: 'id');
print(finalLastSeen);
return product_details_layout(
cartProvider: cartProvider,
product: product,
productId: productId,
wishListProvider: wishListProvider,
sellerImageurl: _sellerImageurl,
sellerName: _sellerName,
sellerCity: _sellerCity,
sellerStatus: _sellerStatus,
userOffline: _userOffline,
productList: productList,
sellerJoinedDate: _sellerJoinedDate,
);
},
);
``