我想在 Flutter Dart 中实现一个插件架构。过程如下: 1. 用户下载应用程序。2. 用户从我们的网站加载插件。3. 应用程序查看插件是否实现了接口。4. 如果实现了接口,则将信息和小部件从插件加载到应用程序。
我已经在 C# 中使用运行时编译的 DLL 加载实现了相同的过程,但无法为 Flutter 找到它。
我已经查看了互联网上可用的一些以前的问题和资源,我发现的最接近的是这个,https://pub.dev/packages/plugins,但 Dart 2 不支持该插件并已弃用
这是我在 C# 中实现的代码。
int i = 0;
if (Directory.Exists("Plugins"))
{
dllFileNames = Directory.GetFiles("Plugins", "*.dll");
ICollection<Assembly> assemblies = new List<Assembly>(dllFileNames.Length);
foreach (string dllFile in dllFileNames)
{
AssemblyName an = AssemblyName.GetAssemblyName(dllFile);
Assembly assembly = Assembly.Load(an);
assemblies.Add(assembly);
}
Type pluginType = typeof(IPlugin);
List<Type> pluginTypes = new List<Type>();
foreach (Assembly assembly in assemblies)
{
if (assembly != null)
{
Type[] types = …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作带有圆角的标签控件。这是我继承自Label的myclass中的OnPaint()重写方法中的代码。
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
LinearGradientBrush brush = new LinearGradientBrush(this.ClientRectangle, GradientColor1, GradientColor2, 90);
e.Graphics.FillRectangle(brush, new Rectangle(new Point(0, 0), new Size(this.Width, this.Height)));
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddArc(new Rectangle(new Point(0, 0), new Size(this.Height, this.Height)), 90, 180);
gp.AddLine(new Point(this.Height / 2, 0), new Point(this.Width - (this.Height / 2), 0));
gp.AddArc(new Rectangle(new Point(this.Width - this.Height, 0), new Size(this.Height, this.Height)), -90, 180);
gp.CloseFigure();
this.Region = new Region(gp);
} …Run Code Online (Sandbox Code Playgroud)