gpt4 book ai didi

flutter - 引发了另一个异常: 'package:flutter/src/widgets/navigator.dart':断言失败:2216行pos 12: '!_debugLocked':不正确

转载 作者:行者123 更新时间:2023-12-03 03:08:53 26 4
gpt4 key购买 nike

我的应用程序运行良好,我只更新了一个文件中的代码,并且在该错误发生之前,我收到了此错误,每个页面都可以正常浏览,现在所有页面都可以正常使用,而不是该页面,我可以从主页导航到该页面
引发了另一个异常:'package:flutter / src / widgets / navigator.dart':断言失败:2216行pos 12:'!_debugLocked':不正确。
我不知道问题在哪里。

import 'package:custom_chewie/custom_chewie.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import 'package:firebase_admob/firebase_admob.dart';

class ChewieDemo extends StatefulWidget {
final String title;

ChewieDemo({this.title = 'Chewie Demo'});

@override
State<StatefulWidget> createState() {
return new _ChewieDemoState();
}
}

class _ChewieDemoState extends State<ChewieDemo> {
int counter=0;
static final MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
keywords: ['Games', 'Puzzles'],
);

BannerAd bannerAd;
InterstitialAd interstitialAd;
RewardedVideoAd rewardedVideoAd;

BannerAd buildBanner() {
return BannerAd(
adUnitId: BannerAd.testAdUnitId,
size: AdSize.banner,
listener: (MobileAdEvent event) {
print(event);
});
}

InterstitialAd buildInterstitial() {
return InterstitialAd(
adUnitId: InterstitialAd.testAdUnitId,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
if (event == MobileAdEvent.failedToLoad) {
interstitialAd..load();
} else if (event == MobileAdEvent.closed) {
interstitialAd = buildInterstitial()..load();
}
print(event);
});
}
TargetPlatform _platform;
VideoPlayerController _controller;

@override
void initState() {
super.initState();
_controller = new VideoPlayerController.network(
'https://github.com/flutter/assets-for-api-docs/blob/master/assets/videos/butterfly.mp4?raw=true',
);
FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
bannerAd = buildBanner()..load();
interstitialAd = buildInterstitial()..load();
}
@override
void dispose(){
super.dispose();
_controller.dispose();
}

@override
Widget build(BuildContext context) {
bannerAd ..load()..show(
anchorOffset: 20.0,
anchorType: AnchorType.top,
);
Future<bool> _onBackPressed() {
if(counter<1){
interstitialAd
..load()
..show();
counter++;
}
else{bannerAd.dispose();
Navigator.pop(context, true);
}

}
return WillPopScope(
child: Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Column(
children: <Widget>[
new Expanded(
child: new Center(
child: new Chewie(
_controller,
aspectRatio: 3 / 2,
autoPlay: true,
looping: true,
),
),
),

new Row(
children: <Widget>[
new Expanded(
child: new FlatButton(
onPressed: () {
setState(() {
_platform = TargetPlatform.android;
});
},
child: new Padding(
child: new Text("Android controls"),
padding: new EdgeInsets.symmetric(vertical: 16.0),
),
),
),
new Expanded(
child: new FlatButton(
onPressed: () {
setState(() {
_platform = TargetPlatform.iOS;
});
},
child: new Padding(
padding: new EdgeInsets.symmetric(vertical: 16.0),
child: new Text("iOS controls"),
),
),
)
],
)
],
),
),
onWillPop: _onBackPressed,
);


}
}

最佳答案

如果在2个对话框在1个屏幕上打开时遇到问题,则只需在此Future中放置一个对话框即可。

Future.delayed(Duration.zero, () {
Navigator. ...
});

关于flutter - 引发了另一个异常: 'package:flutter/src/widgets/navigator.dart':断言失败:2216行pos 12: '!_debugLocked':不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58027568/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com