dart

Create a resizable view in flutter

荒凉一梦 提交于 2021-01-29 09:42:03
问题 I am creating a resizable view for an image. The code is as follows: import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( body: SafeArea( child: ImageManager(), ), ), ); } } final ballRadius = 7.5; class ImageManager extends StatefulWidget { @override _ImageManagerState createState() => _ImageManagerState(); } class

How do i compress a PDF in Flutter?

喜你入骨 提交于 2021-01-29 09:38:23
问题 I built an app for my university where students can access documents such as notes, question papers etc. in PDF format. I am using Firebase Storage for the back-end. I want to compress the PDF files client side. I thought of using ilovepdf.com's API but i'm not able to do that. Is there anyway to do that in dart? any package in flutter? Would be great if someone could help. Thanks. 回答1: You can use any file compression method, not just those specific to PDF. You could use the archive package,

Getting 'Future<Image>' can't be assigned to a variable of type 'Image' in this Flutter/Dart code?

牧云@^-^@ 提交于 2021-01-29 09:25:27
问题 I'm trying create a function to load images in Flutter (Dart) but not sure how to get this code working. I'm getting: A value of type 'Future' can't be assigned to a variable of type 'Image'. Try changing the type of the variable, or casting the right-hand type to 'Image'. import 'dart:typed_data'; import 'dart:ui' as ui; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build

How to reuse the same layout screen without creating a new widget tree branch

我是研究僧i 提交于 2021-01-29 09:04:44
问题 I am developing Flutter Web Application. The object is to reuse the same layout screen widget(Drawer, AppBar) for most of route screen. I have tried create a new Scaffold class and add body widget to each screen. The problem is every time I navigate to a new screen. There is a new (MyScaffold) created on the widget tree. So it is not good for performance. I also tried to use nested router, the problem is nested router is not supported by url that I can not navigate to the screen by typing the

Paytabs payment integration using dart, flutter web and api

主宰稳场 提交于 2021-01-29 09:01:34
问题 I have a flutter web project and I was trying to implement a payment solution. I found out that paytabs is a good choice for my situation. I wanted to add their api but I kept getting the CORS erorr over my flutter website. So I tried their ready payment page but I am also unable to implement since I have no previous knowledge about web development. I only use dart and flutter. But I would like to implement the api since it gives higher control. This is the url used for post requests https:/

DART: Passing function in a function as parameter

此生再无相见时 提交于 2021-01-29 08:57:08
问题 The below snippet of code gives me error in dartpad. But the same code works fine in the course which I am doing online. I am using dart version 2.8.4. void main() { int var = operation(5,5,add); --> Error //print(operation(5,5,add)); } // class calculator { // calculator({this.operand}); // } int add(int n1, int n2) { return n1+n2; } int multiply(int n1, int n2) { return n1*n2; } int operation(int n1, int n2, Function operand){ return operand(n1, n2); } Error: Error compiling to JavaScript:

Changing backgroundcolor depending on variable in flutter

一曲冷凌霜 提交于 2021-01-29 08:47:59
问题 With Flutter i want to change the backgroundcolor of my app whenever the value of "color" variable changes. String color = "white"; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.green, I don't know how to set color to backgroundColor proprety. 回答1: To store your color value, you can use Color type data: Color myColor = Colors.white; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: myColor, After that, you can change the

Redirect to google maps app with directions between source and destination with some stops in flutter

此生再无相见时 提交于 2021-01-29 08:46:11
问题 I want to redirect to google maps app for navigation with some stops between source and destination from my flutter application. url_launcher package redirects to map with source and destination but I want with some stops. Is that possible? 回答1: If you want to navigate with directions you can just create a url with source and destination co-ordinates and other coordinates to add as stops. Steps: 1. Install url_launcher plugin write a code like below. _launchURL(String url) async { if (await

how to display animated images in flutter

可紊 提交于 2021-01-29 08:44:02
问题 In my app i want to represent rolling dice. currently when i roll the dice it move randomly to one of the six images without any animation. all what i want is to display animation scene,it takes 2 second moving between six images as if the dice is rolling. i tried with the setState() but it only work when i click the button is there is a way use setState() in loop and this is my state class class _DicePageState extends State<DicePage> { int leftButtonImage = 2; int rightButtonImage = 3; void

BottomNavigationBar Transparent Background

ぐ巨炮叔叔 提交于 2021-01-29 08:43:41
问题 I'm trying to build a BottomNavigationBar that has no background (transparent), so far this is what I have done, but I still have shadows which should also be removed: return Scaffold( body: body, bottomNavigationBar: Theme( data: Theme.of(context).copyWith( canvasColor: Colors.transparent, primaryColor: Colors.white, textTheme: Theme .of(context) .textTheme .copyWith(caption: TextStyle(color: Colors.deepOrange))), child: BottomNavigationBar( type: BottomNavigationBarType.fixed, currentIndex: