Created
March 14, 2021 18:04
-
-
Save PiN73/c791f64d843a6fa0c980c7b228f2812c to your computer and use it in GitHub Desktop.
Flutter hack Column https://twitter.com/lets4r/status/1371115245444468736
This file contains hidden or 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 '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