lazy_widget 1.0.1 copy "lazy_widget: ^1.0.1" to clipboard
lazy_widget: ^1.0.1 copied to clipboard

discontinued
outdated

A new Flutter package.

example/lib/main.dart

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) {
    try {
      return SvgPicture.asset(
        iv.url,
        color: iv.color,
        package: iv.package,
        fit: iv.fit ?? BoxFit.contain,
        semanticsLabel: 'A red up arrow',
      );
    } catch (e) {
      return Text("svgWidgetBuilder error = $e");
    }
  }, 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) => Column(
        children: [
          Icon(
            Icons.error,
            color: Colors.amber,
          ),
          Text(
            error.toString(),
            style: TextStyle(color: Colors.white60),
          )
        ],
      ),
    );
  });
  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,
              backgroundColor: Colors.yellow,
            ),
            SizedBox(height: 20),
            Container(
                color: Colors.black,
                child: TextWidget(
                  "Flutter",
                  visible: !false,
                  backgroundColor: Colors.green,
                  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,
                )),
            TextWidget("ss"),
            Container(
                color: Colors.black,
                margin: EdgeInsets.all(20),
                child: ImageWidget(
                  "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png",
                )),
            // Container(
            //     color: Colors.black,
            //     margin: EdgeInsets.all(20),
            //     child: ImageWidget(
            //       "assets/a.png",
            //     )),
            TextWidget("assets/a.svg"),
            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.
    );
  }
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter package.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on lazy_widget