Flutters platform channel supports types like null, int, double, string, list, and map. But how can one get platform specific types like drawables?
Asked
Active
Viewed 4,690 times
2 Answers
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
- 306
- 1
- 14
-
1Thanks Spencer. This seems to work. I'll give it a try. – Toni Joe Jul 16 '18 at 18:58
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
- 3