我正在尝试渲染渐变按钮,但在某些设备上,渐变颜色不会像下图那样展开。
我怎样才能解决这个问题?
谢谢!
代码
class GradientButton extends StatelessWidget {
final Widget child;
final VoidCallback onPressed;
const GradientButton({@required this.child, @required this.onPressed});
@override
Widget build(BuildContext context) {
return RaisedButton(
textColor: Colors.white,
shape: StadiumBorder(),
padding: const EdgeInsets.all(0.0),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: <Color>[Color(0xff00F260), Color(0xff0575E6)],
),
),
padding: EdgeInsets.all(8.0),
child: child
onPressed: onPressed,
),
);
}
}
Run Code Online (Sandbox Code Playgroud) Flutter web 现在支持 shared_preferences。我已经添加shared_preferences到我的颤振网络应用程序中。我的问题是当我设置首选项时,比如当我启动应用程序时,它在应用程序的任何地方都可以正常工作,但是当我关闭浏览器并再次启动应用程序并尝试检索它时,它什么都不返回。如何在关闭并启动应用程序后使其工作。
_showPref()async{
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setInt("myKey", 98);
}
@override
void initState() {
// TODO: implement initState
super.initState();
_showPref();
}
// then retrieve with the code
getPrefs(){
SharedPreferences prefs = await SharedPreferences.getInstance();
int count = (prefs.getInt("myKey")??0);
print(" 2. new prefs: $count");
}
Run Code Online (Sandbox Code Playgroud) 在过去的几个月里,我一直对 Flutter 非常感兴趣,并且一直在关注测试版 Flutter 以获取网络信息。我想知道,除了文档(Firebase、Github、Google Cloud)中提到的那些之外,目前是否有一种方法可以通过使用我的 Hostgator 托管来测试我的应用程序并使用 Filezilla 之类的东西来发布应用程序/站点?
我知道这处于测试状态。我只是问,因为文档指出有一种方法可以通过这些服务发布,但没有提到我问的方式。我也明白这不是生产就绪的。
谢谢大家的帮助
我正在尝试在使用 Python 编写的套接字服务器socketio与使用 Flutter Web 制作的客户端之间建立连接。
我测试了各种套接字包,如adhara_socket_io和flutter_socket_io,但没有任何效果。我在 Android 上尝试了相同的代码片段,但它们也不起作用。
我一直在搜索,我找到了这个代码片段。它使用包中的Socket类dart.io。
Socket socket = await Socket.connect('192.168.2.190', 7003);
print('connected');
// listen to the received data event stream
socket.listen((List<int> event) {
print(utf8.decode(event));
});
// send hello
socket.add(utf8.encode('hello'));
// wait 5 seconds
await Future.delayed(Duration(seconds: 5));
// .. and close the socket
socket.close();
Run Code Online (Sandbox Code Playgroud)
这个连接到 Python 服务器并从 Android 发送数据,但是当我从 Web 测试它时,我没有连接。
我需要添加一些额外的东西才能让它在 Web 上工作吗?
或者在最坏的情况下,有没有另一种方法可以做我想做的事情,我的目标是在网站中显示视频源。该视频实际上是一堆从 Python 中获取的图像,将对它们执行一些机器学习,我想通过套接字发送它们,并且每个图像在收到后立即显示,因此看起来像一个视频源。(类似的事情是用 React 完成的)
我正在使用运行良好的 Image Picker web。我可以在 中显示图像Image.memory(),但此图像的格式为 Uintlist8。为了保存在存储需要格式File,我的问题是如何在Firebase Storage 中保存图像。
网络图片选择器:
class _SecondPageState extends State<SecondPage> {
final _formkey = GlobalKey<FormState>();
Uint8List _image;
getImage() async {
Uint8List tempImg = await ImagePickerWeb.getImage(asUint8List: true);
if (tempImg != null) {
setState(() {
_image = tempImg;
});
}
}
Run Code Online (Sandbox Code Playgroud) 我正在创建一个管理仪表板,我目前有两个连续的视图小部件:
这是页面的代码:
import 'package:flutter/material.dart';
import 'package:webenrol/widgets/dashboard_admin.dart';
import 'package:webenrol/widgets/drawer.dart';
//TODO: add flappy_search_bar package and add to appBar
class AdminDashboard extends StatelessWidget {
//TODO: Add title
static String id = '/admin_dashboard';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Admin Dashboard - Overview'),),
body: Container(child: Row(
children: <Widget>[
//Sidebar
DashboardSideBar(),
//Main Dashboard Content
DashboardAdmin(),
],
)),
);
}
}
Run Code Online (Sandbox Code Playgroud)
我将为侧边栏中的链接创建其他内容小部件,我最希望的是,将内容小部件更新为在菜单上单击的内容,并且还将 ListTile 选择为活动状态,而无需重新加载页面。
这可能吗,我的 WebApp 是否为此正确布局,还是我需要更改它?
flutter flutter-layout flutter-navigation flutter-listview flutter-web
我需要在我的网络应用程序中使用相机。所以我想如果用户拒绝在他/她的浏览器上使用相机,我会再次要求它允许相机许可。
这是我的代码
import 'package:universal_html/html.dart' as html;
RaisedButton(
onPressed: () {
var permissions = Map<String,String>();
permissions['name']= 'camera';
html.window.navigator.permissions.request(permissions).then((value){
print((value).state);
});
},
child: Text('Grant Permission'),
)
Run Code Online (Sandbox Code Playgroud)
但是当我单击“授予权限”按钮时,它会记录此错误
html_dart2js.dart:25368 Uncaught (in promise) TypeError: this.request is not a function
at Permissions.[dartx.request] (html_dart2js.dart:25368)
at web_camera_preview_screen.dart:157
at Generator.next (<anonymous>)
at runBody (async_patch.dart:86)
at Object._async [as async] (async_patch.dart:125)
at ink_well.InkWell.new.<anonymous> (web_camera_preview_screen.dart:154)
at _InkResponseState.new.[_handleTap] (ink_well.dart:779)
at ink_well.dart:862
at tap.TapGestureRecognizer.new.invokeCallback (recognizer.dart:182)
at tap.TapGestureRecognizer.new.handleTapUp (tap.dart:504)
at tap.TapGestureRecognizer.new.[_checkUp] (tap.dart:282)
at tap.TapGestureRecognizer.new.handlePrimaryPointer (tap.dart:217)
at tap.TapGestureRecognizer.new.handleEvent (recognizer.dart:475)
at pointer_router.PointerRouter.new.[_dispatch] (pointer_router.dart:76)
at pointer_router.dart:122
at …Run Code Online (Sandbox Code Playgroud) 使用以下命令构建 Flutter Web 应用程序后
flutter build web
Run Code Online (Sandbox Code Playgroud)
我想使用简单的 Django 服务器为应用程序提供服务。我怎样才能做到这一点?
我正在使用 Flutter 开发一个 Web 应用程序。
我在我的应用程序上工作了几天,一切都很好,但是从今天早上开始,我总是在运行应用程序时收到这个警告:
"A null value was passed into a non-nullable parameter value
This will become a failure when runtime null safety is enabled."
Run Code Online (Sandbox Code Playgroud)
在我更改代码中的 RANDOM 内容之前,不会真正发生任何错误,这并不重要。然后出现这个错误:
Error: Invalid argument(s): Extension already registered: ext.flutter.disassemble
at Object.throw_ [as throw] (http://localhost:51499/dart_sdk.js:4461:11)
at Object.registerExtension$ [as registerExtension] (http://localhost:51499/dart_sdk.js:48563:17)
at Object.webOnlyInitializeEngine (http://localhost:51499/dart_sdk.js:163999:15)
at _initializePlatform (http://localhost:51499/dart_sdk.js:134269:15)
at _initializePlatform.next (<anonymous>)
at runBody (http://localhost:51499/dart_sdk.js:36923:34)
at Object._async [as async] (http://localhost:51499/dart_sdk.js:36951:7)
at Object._initializePlatform (http://localhost:51499/dart_sdk.js:134265:18)
at Object.webOnlyInitializePlatform (http://localhost:51499/dart_sdk.js:134257:35)
at main$ (http://localhost:51499/web_entrypoint.dart.lib.js:16:16)
at main$.next (<anonymous>)
at runBody (http://localhost:51499/dart_sdk.js:36923:34)
at …Run Code Online (Sandbox Code Playgroud) 我是 flutter 的初学者,我找到了这个我想使用的包https://pub.dev/packages/flutter_calendar_carousel。我正在尝试将它用于颤振网络应用程序。我去运行了这个例子,它可以工作,但是当我最大化窗口时出现问题,它看起来不太好;大圆圈,与在小窗口中时看起来不一样(大小问题,缩放不好):
我尝试使用 AspectRatio 小部件,它看起来更好,但它仍然太大。我不确定如何正确使用纵横比,但还有其他方法可以解决吗?TLDR;我希望日历可读并根据屏幕大小进行缩放。这是示例 btw 中的代码:
import 'package:flutter_calendar_carousel/flutter_calendar_carousel.dart'
show CalendarCarousel;
import 'package:flutter_calendar_carousel/classes/event.dart';
import 'package:flutter_calendar_carousel/classes/event_list.dart';
import 'package:intl/intl.dart' show DateFormat;
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'dooboolab flutter calendar',
theme: new ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a …Run Code Online (Sandbox Code Playgroud)