Multiline-String to SingleLine-String in Flutter/Dart - flutter

I have TextField with property keyboardType: TextInputType.multiline, which allows me to put and enter/line break on the text. I'm trying to replace all linebreaks with <br> tag to use on web.
String myStr; // initialized with onChanged(value) callback
myStr.replaceAll("\n", "<br>");
print(myStr);
output remains same in multilines:
I/flutter ( 8312): a
I/flutter ( 8312): b
I/flutter ( 8312): c
I/flutter ( 8312): d
I/flutter ( 8312): e
I/flutter ( 8312): f
What I want is :
I/flutter ( 8312): a<br>b<br>c<br>d<br>e<br>f

As per the replaceAll documentation, it returns back the replaced string. You just need to set it back to your myStr:
myStr = myStr.replaceAll("\n", "<br>");

Related

Why flutter building many times?

code screenshot1
When i hot restart app flutter building 3 times
This is output result
Syncing files to device Android SDK built for x86...
Restarted application in 1,018ms.
I/flutter ( 4736): Built Count: 1
I/flutter ( 4736): Built Count: 2
I/flutter ( 4736): writing...
I/flutter ( 4736): writing...
I/flutter ( 4736): reading...:
I/flutter ( 4736): reading...:
I/flutter ( 4736): Built Count: 3
I/flutter ( 4736): writing...
I/flutter ( 4736): reading...:
Constructor of a widget could be called multiple times based on how many places it was declared. As long as you have const constructor and the values passed remains unchanged, the build method won't get trigged multiple times for every initialisation.

phpMyAdmin application crashes with "Fatal error: Uncaught ValueError: mysqli_result::data_seek()"

When I run the query on phpMyAdmin, I get the following error. What is the error in the query I am using?
Query:
SELECT hashtag, total, tarih FROM social_trend WHERE tarih > UNIX_TIMESTAMP() ORDER BY total DESC LIMIT 5
Error:
Fatal error: Uncaught ValueError: mysqli_result::data_seek(): Argument #1 ($offset) must be greater than or equal to 0 in
C:\xampp\phpMyAdmin\libraries\classes\Dbi\DbiMysqli.php:270 Stack trace:
#0 C:\xampp\phpMyAdmin\libraries\classes\Dbi\DbiMysqli.php(270): mysqli_result->data_seek(-1)
#1 C:\xampp\phpMyAdmin\libraries\classes\DatabaseInterface.php(2726): PhpMyAdmin\Dbi\DbiMysqli->dataSeek(Object(mysqli_result), -1)
#2 C:\xampp\phpMyAdmin\libraries\classes\Display\Results.php(4464): PhpMyAdmin\DatabaseInterface->dataSeek(Object(mysqli_result), -1)
#3 C:\xampp\phpMyAdmin\libraries\classes\Display\Results.php(4203): PhpMyAdmin\Display\Results->_getSortedColumnMessage(Object(mysqli_result), 'total')
#4 C:\xampp\phpMyAdmin\libraries\classes\Sql.php(1669): PhpMyAdmin\Display\Results->getTable(Object(mysqli_result), Array, Array, true)
#5 C:\xampp\phpMyAdmin\libraries\classes\Sql.php(1470): PhpMyAdmin\Sql->getHtmlForSqlQueryResultsTable(Object(PhpMyAdmin\Display\Results), './themes/pmahom...', NULL, Array, false, 0, 0, true, Object(mysqli_result), Array, true)
#6 C:\xampp\phpMyAdmin\libraries\classes\Sql.php(2255): PhpMyAdmin\Sql->getQueryResponseForNoResultsReturned(Array, '808rpg', 'social_trend', NULL, 0, Object(PhpMyAdmin\Display\Results), NULL, './themes/pmahom...', NULL, Object(mysqli_result), 'SELECT hashtag,...', NULL)
#7 C:\xampp\phpMyAdmin\import.php(758): PhpMyAdmin\Sql->executeQueryAndGetQueryResponse(Array, false, '808rpg', 'social_trend', NULL, NULL, NULL, NULL, NULL, NULL, 'db_structure.ph...', './themes/pmahom...', NULL, NULL, NULL, 'SELECT hashtag,...', NULL, NULL)
#8 {main} thrown in C:\xampp\phpMyAdmin\libraries\classes\Dbi\DbiMysqli.php on line 270
This is a bug in MySQL8.0. On an empty table it throws this error.
I turned back to MySQL 5.7 and have no issues so far ))

Problem with editing data with sqflite in flutter

What is wrong in this code?
In debug console shown write sql code, but for some reason it doesn't work
Future<void> _toggleTodoItem(TodoItem todo) async {
final int count = await this._db.rawUpdate(
/*sql=*/ '''
UPDATE $kDbTableName
SET content = ${todo.content},
SET number = ${todo.number}
WHERE id = ${todo.id};''');
print('Updated $count records in db.');
}
There is an error
E/SQLiteLog( 7167): (1) near "SET": syntax error in "UPDATE example1_tbl
E/SQLiteLog( 7167): SET content = n,
E/SQLiteLog( 7167): SET number = 1
E/SQLiteLog( 7167): WHERE id = 7;"
E/flutter ( 7167): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: DatabaseException(near "SET": syntax error (code 1 SQLITE_ERROR): , while compiling: UPDATE example1_tbl
E/flutter ( 7167): SET content = n,
E/flutter ( 7167): SET number = 1
E/flutter ( 7167): WHERE id = 7;) sql ' UPDATE example1_tbl
E/flutter ( 7167): SET content = n,
E/flutter ( 7167): SET number = 1
E/flutter ( 7167): WHERE id = 7;' args []}
"UPDATE" syntax doesn't look like that (https://sqlite.org/lang_update.html). You want:
UPDATE example1_tbl SET content = 'n', number = 1 WHERE id = 7
And you should also be using parameters (https://github.com/tekartik/sqflite/blob/master/sqflite/doc/sql.md#parameters). Don't use text inserted into .rawUpdate unless you want to be subject to Bobby Tables attacks (https://bobby-tables.com).

Mediawiki migration error: relation "page" does not exist

I have migrated mediawiki from CentOS 5 to CentOS 6, from Postgres 8.1 to Postgres 8.4.
Everything was fine, until I wanted to acces my main page.
When I do, the following error appears:
> A database error has occurred Query: SELECT
> page_id,page_namespace,page_title,page_restrictions,page_counter,page_is_redirect,page_is_new,page_random,page_touched,page_latest,page_len FROM page WHERE page_namespace = '0' AND page_title = 'Main_Page'
> LIMIT 1 Function: Article::pageData Error: 1 ERROR: relation "page"
> does not exist LINE 1: ...ge_random,page_touched,page_latest,page_len
> FROM page WHER... ^ Backtrace:
>
> #0 /var/www/html/mediawiki_svn/includes/db/Database.php(616): DatabasePostgres->reportQueryError('ERROR: relatio...', 1, 'SELECT
> page_id...', 'Article::pageDa...', false)
> #1 /var/www/html/mediawiki_svn/includes/db/Database.php(1026): Database->query('SELECT page_id...', 'Article::pageDa...')
> #2 /var/www/html/mediawiki_svn/includes/db/Database.php(1106): Database->select('page', Array, Array, 'Article::pageDa...', Array,
> Array)
> #3 /var/www/html/mediawiki_svn/includes/Article.php(369): Database->selectRow('page', Array, Array, 'Article::pageDa...')
> #4 /var/www/html/mediawiki_svn/includes/Article.php(381): Article->pageData(Object(DatabasePostgres), Array)
> #5 /var/www/html/mediawiki_svn/includes/Wiki.php(300): Article->pageDataFromTitle(Object(DatabasePostgres), Object(Title))
> #6 /var/www/html/mediawiki_svn/includes/Wiki.php(60): MediaWiki->initializeArticle(Object(Title), Object(WebRequest))
> #7 /var/www/html/mediawiki_svn/index.php(116): MediaWiki->initialize(Object(Title), NULL, Object(OutputPage),
> Object(User), Object(WebRequest))
> #8 {main}
When I checked the database I could find the tables: objectcache and page
Any ideas?
I have made the mediawiki static since it is going to be archived.

Conditional Where statement syntax or some other solution

#MallUnit is a parameter with value 'Unit 401,Unit 402,Unit 403'
I would like to have a conditional where statement. Assume that before the AND there are other conditions that work just fine. Basically, if ScheduledMallUnitTypeID is null evaluate using the IN condition. Otherwise, use the like clause.
AND
CASE ScheduledMallUnitTypeID IS NULL THEN
ScheduledMallUnitTypeID IN
(
SELECT Value
FROM Toolbox.dbo.ReportingPortalMultiSetParameterFix(#MallUnit)
)
ELSE ScheduledMallUnitTypeID LIKE #MallUnit
END
This would work:
WHERE
( ScheduledMallUnitTypeID IS NULL AND
ScheduledMallUnitTypeID IN
(
SELECT Value
FROM Toolbox.dbo.ReportingPortalMultiSetParameterFix(#MallUnit)
)
)
OR
(
ScheduledMallUnitTypeID IS NOT NULL AND
ScheduledMallUnitTypeID LIKE #MallUnit
)