Created
November 19, 2021 07:28
-
-
Save espresso3389/84269f8fa00ff580485e244c66d923c7 to your computer and use it in GitHub Desktop.
Sample repro for flutter #93615
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:typed_data'; | |
import 'dart:ui' as ui; | |
import 'package:flutter/material.dart'; | |
void main() => runApp(const MyApp()); | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter #93615', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: Scaffold( | |
appBar: AppBar( | |
title: const Text('Flutter #93615'), | |
), | |
body: Container( | |
color: Colors.black, | |
child: Center( | |
child: FutureBuilder<ui.Image>( | |
future: createTestImage(), | |
builder: (context, snapshot) => | |
snapshot.hasData ? RawImage(image: snapshot.data) : const Text('No data loaded.')), | |
), | |
), | |
), | |
); | |
} | |
} | |
Future<ui.Image> createTestImage() async { | |
const width = 256; | |
const height = 256; | |
final data = Uint8List(width * height * 4); | |
// 2.6.0-12.0.pre.670 (858a328712): RGBA => Red fill | |
// latest master : BGRA => Blue fill | |
for (int i = 0; i < data.length; i += 4) { | |
data[i] = 0xff; | |
data[i + 1] = 0; | |
data[i + 2] = 0; | |
data[i + 3] = 0xff; // A | |
} | |
// white pixel | |
// 2.6.0-12.0.pre.670 (858a328712): bottom-left | |
// latest master : top-left | |
data[0] = data[1] = data[2] = 0xff; | |
final descriptor = ui.ImageDescriptor.raw( | |
await ui.ImmutableBuffer.fromUint8List(data), | |
width: width, | |
height: height, | |
pixelFormat: ui.PixelFormat.bgra8888, | |
); | |
final codec = await descriptor.instantiateCodec(); | |
final frame = await codec.getNextFrame(); | |
return frame.image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
flutter/flutter#93615