您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

99 行
3.6 KiB

using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
using Image = Unity.UIWidgets.widgets.Image;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample
{
public class ImageTest : UIWidgetsPanel
{
protected void OnEnable()
{
base.OnEnable();
}
protected override void main()
{
ui_.runApp(new MyApp());
}
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new ExampleApp(),
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(
settings: settings,
pageBuilder: (Buildcontext, animation, secondaryAnimation) => builder(context)
)
);
}
}
class ExampleApp : StatefulWidget
{
public ExampleApp(Key key = null) : base(key)
{
}
public override State createState()
{
return new ExampleState();
}
}
class ExampleState : State<ExampleApp>
{
private float frame = 0;
public override Widget build(BuildContext context)
{
return new Container(
child: new Column(
children: new List<Widget>
{
AnimatedLottie.file("wine.json", frame: frame, curve: Curves.linear),
new Container(
width: 100,
height: 100,
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8))
),
child: Image.file("test.gif", gaplessPlayback: true)
),
new Container(
width: 200,
height: 100,
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8))
),
child: Image.network(
"https://unity-cn-cms-prd-1254078910.cos.ap-shanghai.myqcloud.com/assetstore-cms-media/img-7dfe215f-0075-4f9c-9b5a-be5ee88b866b",
gaplessPlayback: true)
),
new GestureDetector(
onTap: () => { setState(() => { frame += 1; }); },
child: new Container(
color: Color.black,
padding: EdgeInsets.symmetric(20, 20),
child: new Text("Click Me",
style: new TextStyle(fontWeight: FontWeight.w700))
)
)
}
)
);
}
}
}
}