当我在flutter中添加主题数据时,出现此错误

4si2a6ki  于 2023-01-14  发布在  Flutter
关注(0)|答案(1)|浏览(108)
import 'package:flutter/material.dart';
import 'package:my_application_1/pages/home_page.dart';

void main() {
  runApp(my_application_1());

}
class my_application_1 extends StatelessWidget {

  @override
  
  Widget build(BuildContext context) {
    return MaterialApp(
      home: home_page()
      theme: ThemeData(
        primarySwatch: Colors.brown
      ),
    );
    
  }
}

主题中显示错误-Expected to find ','.dart(expected_token)

zbq4xfa0

zbq4xfa01#

您在home: homePage()后面忘了一个“,”。
加进去就行了。

import 'package:flutter/material.dart';
import 'package:my_application_1/pages/home_page.dart';

void main() {
  runApp(my_application_1());

}
class my_application_1 extends StatelessWidget {

  @override
  
  Widget build(BuildContext context) {
    return MaterialApp(
      home: home_page(),
      theme: ThemeData(
        primarySwatch: Colors.brown
      ),
    );
    
  }
}

相关问题