早上好,我正在ios和android的应用程序中以抖动方式实现地图,为此,我使用google_maps_flutter pub程序包,生成了蜜蜂,并按如下所示配置了应用程序。但是,当您执行所有操作时,都会出现以下错误,我会解释应用程序启动,但是,地图未显示,并且显示了以下错误
错误:
引发了另一个异常: 'package:flutter / src / rendering / object.dart':断言失败:行 1651 pos 12:'!_debugDoingThisLayout':不正确。
颤振配置:
v1 = 'vomoyj ziy'
v2 = [['vó', '<SCONJ>'], ['ṁo', '<PART>'], ['yj', '<PRON>'], ['zíy', '<ADJ>']]
import unidecode
def comparison_func(v1,v2):
output_ = []
for token in v2:
converted_token = unidecode.unidecode(token[0])
position = v1.find(converted_token)
output_.append([token[0],v1[position:position+len(converted_token)],position])
return output_
comparison_func(v1,v2)
#op
[['vó', 'vo', 0], ['ṁo', 'mo', 2], ['yj', 'yj', 4], ['zíy', 'ziy', 7]]
AndroidManifest.xml
import 'dart:async';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:App/View/Home/ui_view/mediterranesn_diet_view.dart';
import 'package:App/View/Home/ui_view/title_view.dart';
import 'package:App/View/Home/fintness_app_theme.dart';
import 'package:App/View/Home/MarcaTempo/meals_list_view.dart';
import 'package:flutter/material.dart';
class MyDiaryScreen extends StatefulWidget {
const MyDiaryScreen({Key key, this.animationController}) : super(key: key);
final AnimationController animationController;
@override
_MyDiaryScreenState createState() => _MyDiaryScreenState();
}
class _MyDiaryScreenState extends State<MyDiaryScreen>
with TickerProviderStateMixin {
// 1
Completer<GoogleMapController> _controller = Completer();
// 2
static final CameraPosition _myLocation =
CameraPosition(target: LatLng(40.3, 32.5),);
Animation<double> topBarAnimation;
List<Widget> listViews = <Widget>[];
final ScrollController scrollController = ScrollController();
double topBarOpacity = 0.0;
@override
void initState() {
topBarAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController,
curve: Interval(0, 0.5, curve: Curves.fastOutSlowIn)));
addAllListData();
scrollController.addListener(() {
if (scrollController.offset >= 24) {
if (topBarOpacity != 1.0) {
setState(() {
topBarOpacity = 1.0;
});
}
} else if (scrollController.offset <= 24 &&
scrollController.offset >= 0) {
if (topBarOpacity != scrollController.offset / 24) {
setState(() {
topBarOpacity = scrollController.offset / 24;
});
}
} else if (scrollController.offset <= 0) {
if (topBarOpacity != 0.0) {
setState(() {
topBarOpacity = 0.0;
});
}
}
});
super.initState();
}
void addAllListData() {
const int count = 9;
//Prima view che comprende il titolo della Posizione
listViews.add(
TitleView(
titleTxt: 'Posizione',
subTxt: '',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController,
curve:
Interval((1 / count) * 0, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController,
),
);
listViews.add(
MediterranesnDietView(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController,
curve:
Interval((1 / count) * 1, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController,
),
);
listViews.add(
TitleView(
titleTxt: 'Registrazione',
subTxt: '',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController,
curve:
Interval((1 / count) * 2, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController,
),
);
listViews.add(
MealsListView(
mainScreenAnimation: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController,
curve: Interval((1 / count) * 3, 1.0,
curve: Curves.fastOutSlowIn))),
mainScreenAnimationController: widget.animationController,
),
);
listViews.add(
TitleView(
titleTxt: 'Mappa',
subTxt: '',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController,
curve:
Interval((1 / count) * 2, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController,
),
);
listViews.add(
getMap()
);
}
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 50));
return true;
}
@override
Widget build(BuildContext context) {
return Container(
color: FintnessAppTheme.background,
child: Scaffold(
backgroundColor: Colors.transparent,
body: Stack(
children: <Widget>[
//getMap(),
getMainListViewUI(),
getAppBarUI(),
SizedBox(
height: MediaQuery.of(context).padding.bottom,
)
],
),
),
);
}
Widget getMainListViewUI() {
return FutureBuilder<bool>(
future: getData(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
} else {
return ListView.builder(
controller: scrollController,
padding: EdgeInsets.only(
top: AppBar().preferredSize.height +
MediaQuery.of(context).padding.top +
24,
bottom: 62 + MediaQuery.of(context).padding.bottom,
),
itemCount: listViews.length,
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, int index) {
widget.animationController.forward();
return listViews[index];
},
);
}
},
);
}
//Widget che permette di recuperare la mappa per accedere alla posizione
Widget getMap() {
return Scaffold(
// 1
body: GoogleMap(
// 2
initialCameraPosition: _myLocation,
// 3
mapType: MapType.normal,
// 4
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
),
);
}
//Recupero della barra per la UI
Widget getAppBarUI() {
return Column(
children: <Widget>[
AnimatedBuilder(
animation: widget.animationController,
builder: (BuildContext context, Widget child) {
return FadeTransition(
opacity: topBarAnimation,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - topBarAnimation.value), 0.0),
child: Container(
decoration: BoxDecoration(
color: FintnessAppTheme.white.withOpacity(topBarOpacity),
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(32.0),
),
boxShadow: <BoxShadow>[
BoxShadow(
color: FintnessAppTheme.grey
.withOpacity(0.4 * topBarOpacity),
offset: const Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Column(
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).padding.top,
),
Padding(
padding: EdgeInsets.only(
left: 16,
right: 16,
top: 16 - 8.0 * topBarOpacity,
bottom: 12 - 8.0 * topBarOpacity),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Marcatempo',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FintnessAppTheme.fontName,
fontWeight: FontWeight.w700,
fontSize: 22 + 6 - 6 * topBarOpacity,
letterSpacing: 1.2,
color: FintnessAppTheme.darkerText,
),
),
),
),
],
),
)
],
),
),
),
);
},
)
],
);
}
}
AppDelegate.m
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="{{YOUR_API_KEY_HERE}}"/>
Info.plist
[GeneratedPluginRegistrant registerWithRegistry:self];
[GMSServices provideAPIKey:@"{{YOUR_API_KEY_HERE}}"];
pubspec.yaml
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>