drawable 0.1.0 copy "drawable: ^0.1.0" to clipboard
drawable: ^0.1.0 copied to clipboard

discontinued

Flutter plugin to load Android drawables. This helps to share graphics between Flutter and Android

example/lib/main.dart

import 'package:drawable/drawable.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: ListView(
          children: [
            const ListTile(title: Text('BitmapDrawable')),
            const Image(image: DrawableImage('flutter')),
            const ListTile(title: Text('VectorDrawable')),
            const Image(
              image: DrawableImage('child_care'),
              width: 80,
              height: 80,
            ),
            const ListTile(title: Text('ColorDrawable')),
            ColorDrawableWidget(),
          ],
        ),
      ),
    );
  }
}

class ColorDrawableWidget extends StatefulWidget {
  @override
  _ColorDrawableWidgetState createState() => _ColorDrawableWidgetState();
}

class _ColorDrawableWidgetState extends State<ColorDrawableWidget> {
  Color _color = Colors.transparent;

  @override
  void initState() {
    super.initState();
    loadColor();
  }

  Future<void> loadColor() async {
    final colorDrawable =
        await const AndroidDrawable().loadColor(name: 'example_color');
    setState(() {
      _color = colorDrawable?.color ?? Colors.black;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: _color,
      width: 50,
      height: 50,
    );
  }
}
14
likes
90
pub points
69%
popularity

Publisher

verified publisheruekoetter.dev

Flutter plugin to load Android drawables. This helps to share graphics between Flutter and Android

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on drawable