[英]Separate widgets in other files flutter
I want to make my code neater but I have a problem when I separate widgets that I use often in 1 file我想让我的代码更整洁,但是当我在 1 个文件中分离我经常使用的小部件时遇到问题
here is it my main widget这是我的主要小部件
import 'package:a_tiket/Helpers/widget_helper.dart';
class LoginPage extends StatefulWidget {
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
bool _isLoading = false;
var _message = '';
var _hasError = false;
@override
Widget build(BuildContext context) {
return
_isLoading ?
_loadingWidget(context)
:
Scaffold(
body: SingleChildScrollView(
child: Container(
),
],
),
)
)
)
;
}
}
this is my widget_helper.dart这是我的 widget_helper.dart
Widget _loadingWidget (BuildContext context){
return Scaffold(
body: Center(
child: CircularProgressIndicator(
backgroundColor: ACCENT_COLOR,
valueColor: new AlwaysStoppedAnimation<Color>(PRIMARY_COLOR),
),
),
);
}
the problem is i got some error.问题是我有一些错误。 i have add import for widget_helper but still get error
我已经为 widget_helper 添加了导入,但仍然出现错误
lib/Pages/loginPage.dart:193:7: Error: The method '_loadingWidget' isn't defined for the class '_LoginPageState'.
what should i do?我该怎么办? i just want to make the code neater
我只是想让代码更整洁
please remove underline
请删除
underline
change from从改变
_loadingWidget(context)
to到
loadingWidget(context)
There are a few issues with your code:您的代码存在一些问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.