我基本上想要做的(我做了,细节在前面)是创建一个屏幕,其中包含几个表单,其中的内容使用按钮(NEXT)进行更改。所以我有 3 个表单,当我按下下一步时,我保存第一个表单并传递给另一个表单,当我将我的类放在 main.dart 中时,我到目前为止所做的工作有效。例如,这是我的 main.dart 内容。
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Entries'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
static final _scafoldKey = new GlobalKey<ScaffoldState>();
final firstForm = new FirstForm(title: "First Form");
final secondForm = new SecondForm(title: "First Form",);
final thirdForm = new ThirdForm(title: "First Form");
final Map<int,Widget> …Run Code Online (Sandbox Code Playgroud) 我在 Flutter 中创建了一个扩展 AppBar 类的类,这样我就可以在需要时重用它。我的问题是如何访问有状态/无状态小部件构建上下文?
class AppBarLayout extends AppBar {
static final AppController _appController = new AppController();
final GlobalKey<ScaffoldState> _scaffoldKey;
final String appBarTitle;
AppBarLayout(this.appBarTitle,this._scaffoldKey): super(
title: Text(appBarTitle),
leading: IconButton(
onPressed: () => _scaffoldKey.currentState.openDrawer(),
iconSize: 28,
icon: Icon(Icons.menu,color: Colors.white),
),
actions: <Widget>[
IconButton(
onPressed: () => _appController.signOut().then((_) {
_appController.navigateTo(context, new GoogleSignView());
}),
icon: Icon(Icons.account_box),
padding: EdgeInsets.all(0.0),
),
],
);
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 Flutter 制作一个使用地图的移动应用程序。我们决定使用谷歌地图,我们使用的flutter插件是:
google_maps_flutter:^0.5.7
我了解向地图添加标记的工作方式如下:
Map<MarkerId, Marker> markers = <MarkerId, Marker>{};
Marker _marker = new Marker(
icon: BitmapDescriptor.defaultMarker,
markerId: _markerId,
position: LatLng(34.024441,-5.0310968),
infoWindow: InfoWindow(title: "userMarker", snippet: '*'),
);
GoogleMap _map;
@override
void initState(
markers[_markerId] = _marker;
_map = new GoogleMap(
/* other properties irrelevant to this prob */
markers: Set<Marker>.of(_markers.values),
);
);
Run Code Online (Sandbox Code Playgroud)
上面的片段确实有效,我可以看到地图上的标记。但是修改标记或尝试添加另一个标记(如下面的代码段所示)不起作用。
FloatingActionButton(
onPressed: () {
setState(() {
_marker = new Marker(
icon: BitmapDescriptor.defaultMarker,
markerId: _markerId,
position: LatLng(currentLocation.latitude, currentLocation.longitude),
infoWindow: InfoWindow(title: "userMarker", snippet: '*'),
onTap: () {
debugPrint("Marker Tapped"); …Run Code Online (Sandbox Code Playgroud) UML中的配置文件图是什么?更具体地说,此图的作用是什么?我们可以将其用于什么(我们可以使用它来解决的问题,或者我们可以使用它来简化的解决方案)?
编译包含此类的代码:
class Dessin
{
private:
vector<Figures*>T;
public:
void ajouteFigure(const Figures& f) const
{
for(auto element: T)
{
T.push_back(f);
}
}
};
Run Code Online (Sandbox Code Playgroud)
产生错误:
[错误]没有匹配函数调用'std :: vector :: push_back(const Figures&)const'
这是我应该在main()中做的事情
Dessin s;
s.ajouteFigure(Cercle(1.1));
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用?