我是 flutter 和 dart 的新手,我正在尝试克隆 Instagram 以用于学习目的,但我收到以下错误。
你能帮我找出代码哪里不正确吗?
最后输出消息错误。
我尝试谷歌,并重构代码以应用空安全,但实际上我不知道错误的代码到底在哪里。
主程序.dart
import 'package:flutter/material.dart';
import 'package:instagram_flutter/responsive/mobile_screen_layout.dart';
import 'package:instagram_flutter/responsive/responsive_layout_screen.dart';
import 'package:instagram_flutter/responsive/web_screen_layout.dart';
import 'package:instagram_flutter/utils/colors.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Instagram Clone',
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: mobileBackgroundColor,
),
home: ResponsiveLayout(
webScreenLayout: WebScreenLayout(),
mobileScreenLayout: MobileScreenLayout(),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
mobile_screen_layout.dart
import 'package:flutter/material.dart';
class MobileScreenLayout extends StatelessWidget {
const MobileScreenLayout({super.key}); …Run Code Online (Sandbox Code Playgroud)