dart

flutter pull up to refetch data from api

给你一囗甜甜゛ 提交于 2021-01-29 16:57:51
问题 I want to use Refresh indicator so that when you pull up the page you are in right now rebuilds i will share with you my code i have tried many times but really i can't find a straight way around it here is my code class Companies { final int id; final String name; final String companyLogo; Companies({this.id, this.name, this.companyLogo}); factory Companies.fromJson(Map<String, dynamic> json) { return Companies( id: json['id'], name: json['name'], companyLogo: json['company_logo'], ); } }

How to convert string to raw string in dart

谁都会走 提交于 2021-01-29 16:37:08
问题 I want to convert an existing string to raw string. like: String s = "Hello \n World" I want to convert this s variable to raw string(I want to print exact "Hello \n Wrold") I need backslash(\) in output. I am trying to fetch string value from rest api. it have bunch of mathjax(latex) formula containing backslash. Thanks 回答1: You are asking for a way to escape newlines (and possibly other control characters) in a string value. There is no general way to do that for Dart strings in the

Flutter : I have error when work with tow dropdown button load one from another

笑着哭i 提交于 2021-01-29 16:27:18
问题 Hello i am work with flutter drop down menu . firs menu for location . and second for sublocation . it is work when click on first location but when change to second and click second location this error appear "'package:flutter/src/material/dropdown.dart': Failed assertion: line 620 pos 15: 'items == null || items.isEmpty || value == null || items.where((DropdownMenuItem item) => item.value == value).length == 1': is not true. " my variable //location String _myLocation ; List data = List();

Flutter sqflite: Database unstable after hot reload

自作多情 提交于 2021-01-29 16:23:45
问题 I have the following code Future<InitData> getInitialData() async { print('OPENING'); await open(); print('DB = $_db ${_db.isOpen}'); final rawDayActionTypes = await _db.query(...); Where function open is the following Future<Database> open() async { if (_db != null && _db.isOpen) { return _db; } final dbPath = await sql.getDatabasesPath(); final myDBPath = path.join(dbPath, db_name); _db = await sql.openDatabase(myDBPath, onCreate: _onCreateDB, version: 1); return _db; } But after a hot

Flutter image not showing on google marker

不羁的心 提交于 2021-01-29 15:37:21
问题 I am showing an image instead of the normal marker but don't know why it's not showing, I am doing same way on other map page and its working -_- mean the same way I am doing as I am doing here its showing simple red marker on this page and another page I can see my image marker. This is my page code where the issue is class _TripRouteScreenState extends State<TripRouteScreen> { var start_currentPostion; var end_currentPostion; BitmapDescriptor pinLocationIcon; Map<MarkerId, Marker>

flutter bloc and how a bloc state change can then trigger a 2nd async call before updating the Widget/UI with both? (code attached)

此生再无相见时 提交于 2021-01-29 15:32:52
问题 How would one load a set of local images for display in a widget (noting this is async - see function below) triggered by (based on) a change in state from a flutter_bloc for “settings”? Noting this bloc is persisted too via hydrated_bloc. So the use case for which I’m asking how do I code this in flutter (noting I’m using flutter_bloc) is: Use Case - Render different set of images on the same Widget I have for dynamically displaying a room for a 2D point & click adventure type game, BASED ON

Duplicate Keys Error in Flutter List View

不问归期 提交于 2021-01-29 15:22:04
问题 I have this form that is filled out and then when submitted, it makes a separate List Tile in List View in Nosql. Here is the part where I make the 'food' item and on 'submit' button clicked, it makes the item and sends it to list view on the next screen. Notice how each food item has a uniqueID which is Uuid random string. class FoodForm extends StatefulWidget { final Food food; final int foodIndex; FoodForm({this.food, this.foodIndex}); @override State<StatefulWidget> createState() { return

Rendering issue while centering Font Awesome icon

前提是你 提交于 2021-01-29 14:34:34
问题 I don't understand why this FAB doesn't center it's child. I've tried different things but cannot make it to center perfectly. Because adding for example padding only bottom to the icon could make it center on a Device but maybe not for all. this is my code Theme( data: Theme.of(context).copyWith( highlightColor: Colors.red, splashColor: Colors.red), child: SizedBox( height: MediaQuery.of(context).size.height / 7, width: MediaQuery.of(context).size.height / 7, child: FloatingActionButton(

Flutter assets image not find

好久不见. 提交于 2021-01-29 14:27:04
问题 I use Visual studio code and Andriod studio IDE and different AVD managers but when I run app with Image asset get an error No file or variants found for asset: assets/puffin.jpeg. Simple example: main.dart import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { var title = 'Web Images'; return MaterialApp( title: title, home: Scaffold( appBar: AppBar( title: Text(title), ), body: Container(

Align Scrollable Tabs On Left

我只是一个虾纸丫 提交于 2021-01-29 14:09:12
问题 When i set my tabs to scrollable, it will set all my tabs to the center. But i want to find a way that i can align all the tabs to the left. Is there a way for me align the tabs on the left instead of center? Here is my code. Thank you. class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: colorPrimary, accentColor: colorAccent,