我想处理带有一些错误消息的 http 请求抖动,但我在这里遇到了很多错误。我只是根据建议制作它,但它对我不起作用。请任何人帮助我这是我调用API的函数
getData(data, apiUrl) async {
var tempUrl = _url + apiUrl + await _getToken();
Uri uri = Uri.parse(tempUrl);
var fullUrl = uri.replace(queryParameters: data);
var res;
try {
var response = await http.get(fullUrl, headers: _setHeaders()).timeout(
const Duration(seconds: 60));
print(response.statusCode);
if (response.statusCode != 200) {
res = {
"success": false,
"status": response.statusCode,
"message": _returnResponse(response)
};
}
else {
res = response;
}
}
on SocketException {
throw FetchDataException('No Internet connection');
}
on TimeoutException catch (e) {
res = {
"success": …Run Code Online (Sandbox Code Playgroud) 我需要在数据名称后显示图表的值,例如([数据颜色] 汽车 50,[数据颜色] 摩托车 200)。我尝试过更改图例标题的值,但它根本不起作用
这是我的代码:
var ctx = document.getElementById('top-five').getContext('2d');
var myChartpie = new Chart(ctx, {
type: 'pie',
data: {
labels: {!! $top->pluck('name') !!},
datasets: [{
label: 'Statistics',
data: {!! $top->pluck('m_count') !!},
backgroundColor: {!! $top->pluck('colour') !!},
borderColor: {!! $top->pluck('colour') !!},
}]
},
options: {
plugins: {
legend: {
display: true,
title: {
text: function(context) {//I've tried to override this but doesn't work
var value = context.dataset.data[context.dataIndex];
var label = context.label[context.dataIndex];
return label + ' ' + value;
},
}
}, …Run Code Online (Sandbox Code Playgroud) SharedPreferences和之间有什么区别Redux,特别是在颤振方面?Redux在应用程序中提供全局状态。那么两者谁的实力最强呢?关于这两件不同的事情,我应该了解哪些最重要的事情?
我想在抽屉导航底部进行注销和设置,但我尝试了很多建议,但没有任何建议?
这是我的抽屉导航
Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
_createHeader(),
_createDrawerItem(icon: Icons.event, text: 'Event', onTap: () => Navigator.pushReplacementNamed(context, Routes.event)
),
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
_createFooterItem(icon: Icons.event, text: 'Settings', onTap: () => Navigator.pushReplacementNamed(context, Routes.event)),
_createFooterItem(icon: Icons.event, text: 'Logout', onTap: () => Navigator.pushReplacementNamed(context, Routes.event))
],
),
],
),
);
Run Code Online (Sandbox Code Playgroud)
这是我的标题小部件
Widget _createHeader() {
return DrawerHeader(
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage('res/images/drawer_header_background.png'))),
child: Stack(children: <Widget>[
Positioned(
bottom: 12.0,
left: 16.0,
child: Text("Flutter …Run Code Online (Sandbox Code Playgroud) 我想让我的代码更整洁,但是当我在 1 个文件中分离我经常使用的小部件时遇到问题
这是我的主要小部件
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(
),
],
),
)
)
)
;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 widget_helper.dart
Widget _loadingWidget (BuildContext context){
return Scaffold(
body: Center(
child: CircularProgressIndicator(
backgroundColor: ACCENT_COLOR,
valueColor: new AlwaysStoppedAnimation<Color>(PRIMARY_COLOR),
),
),
);
}
Run Code Online (Sandbox Code Playgroud)
问题是我有一些错误。我已经为 …
我想将对象添加到我的状态,我已经搜索解决它,但所有这些都不起作用
this.state = {
value : {name:'test'}
};
Run Code Online (Sandbox Code Playgroud)
我想在 this.state.value 中添加一个对象 {coordinate:'0,0'}
我试过这个,但我得到了错误:传播不可迭代实例的尝试无效
let floors = [...this.state.value];
floors.push({ coordinate: '0,0'});
this.setState({ value:floors });
Run Code Online (Sandbox Code Playgroud)
我试过这个,但我得到了错误:传播不可迭代实例的尝试无效
this.setState({
value:[...this.state.value, {coordinate: '0,0'}]
});
Run Code Online (Sandbox Code Playgroud)
我试过这个,但我得到了错误:_this2.state.value.concat is not a function
this.setState( {
value: this.state.value.concat({koordinat:coor})
});
Run Code Online (Sandbox Code Playgroud)
请帮我解决它
我为身份验证添加了1个属性,但是它不起作用。我什么都不会改变
在我的LoginController中添加此2方法
protected function credentials(Request $request)
{
return $request->only($this->username(), 'password', 'division_id');
}
/**
* Attempt to log the user into the application.
*
* @param \Illuminate\Http\Request $request
* @return bool
*/
protected function attemptLogin(Request $request)
{
$request->merge(['division_id' => '1']);
return $this->guard()->attempt(
$this->credentials($request), $request->filled('remember')
);
}
Run Code Online (Sandbox Code Playgroud)
我只想登录精确的Division_id 1
authentication laravel laravel-5 laravel-5.6 laravel-authentication
我想获得1-3的数组值,但包括'.' 每一次分裂.示例有一个text ="no.this.is.just.example"我想只取0-2索引,所以$ merge将是"no.this.is"
我试过了
$cut = 3;
$text = explode('.',"no.this.is.just.example");
for($i=0; $i<$cut;$i++){
if($cut-1==$i){
$merge .= $text[$i];
}
else{
$merge .= $text[$i].'.';
}
}
Run Code Online (Sandbox Code Playgroud)
有最简单的方法吗?
flutter ×4
dart ×3
laravel ×3
arrays ×1
chart.js ×1
controller ×1
exception ×1
http ×1
httprequest ×1
javascript ×1
laravel-5 ×1
laravel-5.6 ×1
php ×1
react-native ×1
reactjs ×1
redux ×1
regex ×1
widget ×1