#flutter #initState #tips
The error you're encountering is caused by trying to update the UI (
To resolve this issue, you should delay the update until after the build phase. You can achieve this by using WidgetsBinding.instance.addPostFrameCallback, which schedules the code to run after the current frame has been rendered.
The error you're encountering is caused by trying to update the UI (
noteModel.content = '#${noteModel.initialTag}\n';) within the initState method, which triggers a rebuild of the widget while it is still in the build phase. This is not allowed in Flutter, as it can lead to inconsistent states.To resolve this issue, you should delay the update until after the build phase. You can achieve this by using WidgetsBinding.instance.addPostFrameCallback, which schedules the code to run after the current frame has been rendered.
#happynotes' new domain, happynotes.today is online. 🎉
下面是Web前端在CloudFlare上的自动部署代码。感谢CloudFlare免费提供部署空间。
#code #cloudflare
下面是Web前端在CloudFlare上的自动部署代码。感谢CloudFlare免费提供部署空间。
set -x && if cd flutter; then git pull && cd .. ; else git clone https://github.com/flutter/flutter.git; (cd flutter && git fetch --tags && git checkout 3.27.3); fi && ls && flutter/bin/flutter doctor && flutter/bin/flutter clean && flutter/bin/flutter config --enable-web && cp .env.production .env && sed -i "s/VERSION_PLACEHOLDER/`git rev-parse --short HEAD`/" .env && flutter/bin/flutter build web --base-href="/" --release
#code #cloudflare
happynotes.today
happy_notes
A new Flutter project.
The following c# code splits the
### Explanation
1.
- This uses the
- It transforms the
-
-
2.
- The
-
-
3.
- This converts each group (or chunk) into a list.
4.
- This final
### Alternative
Claude.AI suggests a better way to achieve the same goal, which has better simplicity and readability.
#csharp #tips
clientIds into smaller lists, each containing up to 100 elements.var listOfClientIdLists = clientIds
.Select((v, i) => new { Value = v, Index = i })
.GroupBy(g => g.Index / 100, gi => gi.Value)
.Select(chunk => chunk.ToList())
.ToList();
### Explanation
1.
Select((v, i) => new { Value = v, Index = i }):- This uses the
Select method with an overload that provides both the element (v) and its index (i).- It transforms the
clientIds collection into a new collection of anonymous objects, each containing:-
Value: the original element (v).-
Index: the position of the element in the original list (i).2.
GroupBy(g => g.Index / 100, gi => gi.Value):- The
GroupBy method organizes the elements into groups.-
g => g.Index / 100: This lambda expression determines the group key by dividing the index by 100. This effectively groups the elements into chunks of 100.-
gi => gi.Value: This specifies that only the Value part of the anonymous object should be included in the groups.3.
Select(chunk => chunk.ToList()):- This converts each group (or chunk) into a list.
4.
ToList():- This final
ToList converts the collection of lists into a list of lists.### Alternative
Claude.AI suggests a better way to achieve the same goal, which has better simplicity and readability.
var listOfClientIdLists = clientIds
.Chunk(100)
.Select(chunk => chunk.ToList())
.ToList();
#csharp #tips
#flutter #markdown
行内代码
1. 行内code也要包在一个
2. 行内code的样式不能有
3. 行内code的样式不可以直接用
鸣谢Master Markdown and Multi-line Selection in Flutter: A Step-by-Step Tutorial
行内代码
inline code不能选中复制的问题终于解决了,要怪自己当初抄作业的时候没有抄全。几个要点:1. 行内code也要包在一个
Container里2. 行内code的样式不能有
backgroundColor3. 行内code的样式不可以直接用
style: preferredStyle鸣谢Master Markdown and Multi-line Selection in Flutter: A Step-by-Step Tutorial
Medium
Flutter markdown: Using Markdown with Cross-Line Selection in Flutter
Recently, I have been developing Moli AI and it requires support for markdown rendering and multi-line copying. This article primarily…
#csharp
## 用途
在.NET应用程序中,默认情况下会添加多个日志提供程序,例如控制台、调试、EventSource和EventLog等。这些提供程序会在应用程序运行时记录日志信息。如果开发者希望自定义日志记录的行为或只使用特定的日志提供程序,可以通过调用
在这个示例中,首先清除了所有默认的日志提供程序,然后仅添加了控制台日志记录提供程序。这种做法可以帮助开发者避免日志输出的冗余,并确保只使用特定的日志记录方式,提升日志的管理和可读性12。
Citations:
1 https://learn.microsoft.com/zh-cn/dotnet/core/extensions/logging-providers
2 https://learn.microsoft.com/zh-cn/aspnet/core/fundamentals/logging/?view=aspnetcore-8.0
builder.Logging.ClearProviders(); 这一行代码的主要作用是清除当前日志记录构建器中所有已注册的日志提供程序。这通常用于在创建新的日志记录配置时,确保不使用默认的日志提供程序。## 用途
在.NET应用程序中,默认情况下会添加多个日志提供程序,例如控制台、调试、EventSource和EventLog等。这些提供程序会在应用程序运行时记录日志信息。如果开发者希望自定义日志记录的行为或只使用特定的日志提供程序,可以通过调用
ClearProviders来移除所有默认的提供程序,然后添加所需的提供程序,例如:builder.Logging.ClearProviders();
builder.Logging.AddConsole();
在这个示例中,首先清除了所有默认的日志提供程序,然后仅添加了控制台日志记录提供程序。这种做法可以帮助开发者避免日志输出的冗余,并确保只使用特定的日志记录方式,提升日志的管理和可读性12。
Citations:
1 https://learn.microsoft.com/zh-cn/dotnet/core/extensions/logging-providers
2 https://learn.microsoft.com/zh-cn/aspnet/core/fundamentals/logging/?view=aspnetcore-8.0
Docs
日志记录提供程序 - .NET
了解如何在 .NET 应用程序中使用日志记录提供程序 API。