У меня есть мобильное приложение с флаттером, после страницы входа оно перенаправляется на домашнюю страницу, как показано ниже:
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
var m_id;
var u_id;
// get logined user profile
var logined_user;
var logined_email;
getuser() async {
SharedPreferences preferences = await SharedPreferences.getInstance();
logined_user = preferences.getString('username');
logined_email = preferences.getString('email');
if (logined_user != null) {
setState(() {
logined_user = preferences.getString('username');
logined_email = preferences.getString('email');
});
}
var data = {'username': logined_user};
var url = "http://10.0.2.2/jiyan/test/api/users/status_user.php";
var response = await http.post(
url,
body: data,
);
var responsebody = jsonDecode(response.body);
if (responsebody['status'] == 'success') {
setState(() {
m_id = responsebody['m_id'];
});
} else {
print(responsebody['status']);
}
}
@override
void initState() {
getuser();
super.initState();
}
//App Start
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async => false,
child: Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text(
'ژیان و قورئان',
style: TextStyle(fontSize: 30),
),
centerTitle: true,
),
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/background.png"),
fit: BoxFit.cover,
),
),
child: ListView(
padding: EdgeInsets.all(10),
children: <Widget>[
//course 1
InkWell(
onTap: () {
Navigator.of(context).pushNamed('week');
},
child: Image(
image: AssetImage('assets/images/months/Months1.png'))),
//course 2
buildInkWellCourses(context, '2'),
//course 3
buildInkWellCourses(context, '3'),
//course 4
buildInkWellCourses(context, '4'),
//course 5
buildInkWellCourses(context, '5'),
//course 6
buildInkWellCourses(context, '6'),
//course 7
buildInkWellCourses(context, '7'),
//course 8
buildInkWellCourses(context, '8'),
//course 9
buildInkWellCourses(context, '9'),
//course 10
buildInkWellCourses(context, '10'),
//course 11
buildInkWellCourses(context, '11'),
//course 12
buildInkWellCourses(context, '12'),
//course 13
buildInkWellCourses(context, '13'),
],
),
),
),
);
}
InkWell buildInkWellCourses(BuildContext context, coursenum) {
return InkWell(
onTap: () {
if (int.parse(m_id) > int.parse(coursenum) - 1) {
Navigator.of(context).pushNamed('week');
}
},
child: int.parse(m_id) >= int.parse(coursenum)
? Image(
image: AssetImage(
'assets/images/months/Months' + coursenum + '.png'))
: Image(
image: AssetImage(
'assets/images/months/Months' + coursenum + 'closed.png')));
}
}
когда я запускаю приложение на эмуляторе, я получаю эту ошибку:
Недействительный аргумент (ы): источник не должен быть нулевым. Соответствующим виджетом, вызывающим ошибку, был Home # 0 int.parse (dart: core-patch / integers_patch.dart: 53: 25) # 1 _HomeState.buildInkWellCourses package: jiyanUquraan / pages /home.dart:122 # 2 _HomeState.build пакет: jiyanUquraan / pages / home.dart: 84 # 3 StatefulElement.build пакет: flutter /… / widgets / framework.dart: 4619 # 4 ComponentElement.performRebuild
Как я могу исправить эту ошибку