我如何使用get.snackbar?
每当我尝试调用 get.snackbar 时,都没有显示小吃店?根据 pub.dev 页面,我只需要使用
Get.snackbar(
'User 123',
'Successfully created',
);
但是每当我在我的代码中使用它时,都没有显示小吃店?我用错了吗?感谢您的帮助!
回答
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(GetMaterialApp( // You need to change Material App to GetMaterialApp
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_State createState() => _State();
}
class _State extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter - Snackbar USing Get'),
),
body: Center(
child: Column(children: <Widget>[
RaisedButton(
textColor: Colors.white,
color: Colors.green,
child: Text('Show SnackBar'),
onPressed: () {
Get.snackbar(
'User 123',
'Successfully created',
snackPosition: SnackPosition.BOTTOM
);
},
),
])));
}
}