2

Flutters platform channel supports types like null, int, double, string, list, and map. But how can one get platform specific types like drawables?

Toni Joe
  • 5,505
  • 8
  • 41
  • 62

2 Answers2

2

You may be able to convert your Drawables into a Bitmap and then convert the Bitmap into a base64 string and send it over the platform channel and convert the image back using the Image.memory constructor in Flutter. I'm not sure about the limitations on string size through the platform channels, but it should work as long as your images aren't huge.

Here are the answers I referenced: https://stackoverflow.com/a/9224180/8338783 and https://stackoverflow.com/a/46146008/8338783

Spencer
  • 146
  • 10
0

You can also use this library.

import 'package:drawable/drawable.dart';

Widget build(BuildContext context) {
  return MaterialApp(
    home: Scaffold(
      body: Center(
        child: Image(image: DrawableImage("drawable_id")),
      ),
    ),
  );
}

Where "drawable_id" is the last part in R.drawable.drawable_id

ueman
  • 1
  • 2