I'm returning user data and a token if the login data is correct. i want to pass the user data from the login page to other screens and use it within the app.
Below is the data i want to send to other screens...
data: {key: 4fd863897407cdf68e0ee073fcf08f7224d8aa25, user: {id: 2, first_name: Lina, last_name: Jorevaa, username: lina, email: lina@gmail.com, is_super_doc: false, is_doc: true}}
my mobile app ui is built with flutter while my rest api is built with django rest framework and rest-auth
*my login.dart*
Future<List> loginData() async {
final response = await http
.post('http://192.xxx.xxx.xxxx:42366/api/v1/rest-auth/login/', headers: {
'Accept': 'application/json'
}, body: {
'email': '${emailController.text.trim().toLowerCase()}',
'password': '${passwordController.text}'
});
setState(() {
status = response.body.contains('error');
data = json.decode(response.body);
if (status) {
setState(() {
_showDialog();
});
print('data: ${data['error']}');
} else {
print('data: $data');
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) => HomeScreen(
list: data,
index: 1,
),
),
(Route<dynamic> route) => false,
);
}
});
return data;
}
*my home.dart*
class HomeScreen extends StatelessWidget {
final List list;
final int index;
HomeScreen({this.list, this.index});
This is the error i am getting
Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'FutureOr<List<dynamic>>'
Expecting clarification
>'