我正在使用新的 dart 版本 >=2.12.0 <3.0.0 并启用空安全。
我已经添加了我的代码以供参考。
import 'package:cric_app/AppUrls.dart';
import 'package:cric_app/features/home/match_model.dart';
import 'package:dio/dio.dart';
import 'package:rxdart/rxdart.dart';
class MatchesService {
// ignore: close_sinks
BehaviorSubject<List<MatchModel>> list = BehaviorSubject<List<MatchModel>>();
Future<List<MatchModel>> getMatches() async {
try {
var matchList = await fetchMatches();
list.add(matchList);
return matchList;
} catch (Exc) {
print(Exc);
}
}
Future<List<MatchModel>> fetchMatches() async {
var dio = Dio();
final response = await dio.post(AppUrls.getMatches);
print(response.data);
final body = response.data['matches'] as List;
return body.map((dynamic json) {
return MatchModel(
id: json['id'] as int,
date: json['date'] as …Run Code Online (Sandbox Code Playgroud) 我正在开发一个 android 应用程序,它向用户展示来自各个领域的最新工作。当显示工作时以及当用户单击查看更多时,工作描述不会显示。
我已将数据从片段传递到新活动并将其显示在新活动中。没有错误,但没有显示详细信息。我附上了代码和 firebase 数据库结构。
这是 WorkFragment.java 文件,它显示了 recyclerview 中的作业。
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.database.annotations.Nullable;
import java.util.ArrayList;
public class WorkFragment extends Fragment {
DatabaseReference databaseReference;
RecyclerView recyclerView;
FirebaseDatabase firebaseDatabase;
ArrayList<Jobs> jobs;
MyAdapter adapter;
ProgressDialog pd;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_work, …Run Code Online (Sandbox Code Playgroud)