Skip to content

Instantly share code, notes, and snippets.

@PiN73
Created March 14, 2021 18:04
Show Gist options
  • Save PiN73/c791f64d843a6fa0c980c7b228f2812c to your computer and use it in GitHub Desktop.
Save PiN73/c791f64d843a6fa0c980c7b228f2812c to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("1"),
MyAnotherWidget(),
Text("2"),
],
),
),
),
);
}
}
// for normal use-case of custom render objects see
// https://nicksnettravels.builttoroam.com/create-a-flutter-widget/
class MyAnotherWidget extends SingleChildRenderObjectWidget {
@override
RenderMyAnotherWidget createRenderObject(BuildContext context) {
return RenderMyAnotherWidget();
}
}
class RenderMyAnotherWidget extends RenderProxyBox {
@override
void paint(PaintingContext context, Offset offset) {
Future.delayed(
Duration.zero,
() {
// print(parent);
(parent as RenderFlex)
// ..direction = Axis.horizontal
// ..textDirection = TextDirection.ltr
..verticalDirection = VerticalDirection.up;
},
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment