lazy_widget 0.0.3 lazy_widget: ^0.0.3 copied to clipboard
A new Flutter package.
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:lazy_widget/lazy_widget.dart';
import 'three_stooges.dart';
///
import 'package:cached_network_image/cached_network_image.dart';
void main() {
ImageWidgetComponent.init(svgWidgetBuilder: (iv) {
return SvgPicture.asset(iv.url,
color: iv.color,
package: iv.package,
fit: iv.fit,
semanticsLabel: 'A red up arrow');
}, errorBuilder: (iv) {
return SizedBox(
child: Icon(
Icons.error_outline,
color: Colors.red,
),
width: iv.width,
height: iv.height,
);
}, netWorkWidgetBuilder: (iv) {
return CachedNetworkImage(
imageUrl: iv.url,
width: iv.width,
height: iv.height,
fit: iv.fit,
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(
Icons.error,
color: Colors.amber,
),
);
});
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
var imgUrl =
"https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png";
@override
Widget build(BuildContext context) {
var textWidget = TextWidget(
"Flutter",
visible: !false,
backgroundColor: Colors.blue,
radius: 5,
isClipOval: true,
width: 50,
height: 50,
alignment: Alignment.center,
margin: EdgeInsets.all(10),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: const Text('A SnackBar has been shown.')),
);
},
);
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
children: <Widget>[
TextWidget("$textWidget",maxLines: 6,
alignment: Alignment.center,),
SizedBox(height: 20),
Container(
color: Colors.black,
child: TextWidget(
"Flutter",
visible: !false,
backgroundColor: Colors.blue,
radius: 5,
isClipOval: true,
width: 50,
height: 50,
alignment: Alignment.center,
margin: EdgeInsets.all(10),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text('A SnackBar has been shown.')),
);
},
)),
SizedBox(height: 20),
Container(
color: Colors.black,
child: TextWidget(
"Flutter 是 Google推出并开源的移动应用开发框架"
",主打跨平台、高保真、高性能。开发者可以通过 Dart语言开发 App,"
"一套代码同时运行在 iOS 和 Android平台。 Flutter提供了丰富的组件、"
"接口,开发者可以很快地为 Flutter添加 native扩展。同时 Flutter还使用 Native引擎渲染视图,这无疑能为用户提供良好的体验。",
visible: !false,
maxLines: 3,
backgroundColor: Colors.blue,
radius: 5,
// isClipOval: true,
// width: 50,
// width: double.infinity,
height: 110,
// textAlign: TextAlign.center,
// alignment: Alignment.center,
margin: EdgeInsets.all(10),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text('A SnackBar has been shown.')),
);
},
)),
Container(
color: Colors.black,
margin: EdgeInsets.all(20),
child: ImageWidget(
imgUrl,
)),
Container(
color: Colors.black,
margin: EdgeInsets.all(20),
child: ImageWidget(
imgUrl + "ss",
)),
// Container(
// color: Colors.black,
// margin: EdgeInsets.all(20),
// child: ImageWidget(
// "assets/a.png",
// )),
// Container(
// color: Colors.black,
// margin: EdgeInsets.all(20),
// child: ImageWidget(
// "assets/a.svg",
// )),
TextWidget(
'$_counter',
backgroundColor: Colors.blue,
style: Theme.of(context).textTheme.display1,
),
FlatButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return ThreeStoogesPage();
}));
},
child: Text("data")),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}