A definitive guide to RenderObjects in Flutter
Why Stack Overflow recommends it
Stack Overflow users link it when answering Flutter layout and custom painting questions that call for writing a custom RenderObject.
Recommended by 2 people across 2 different months, 2021 to 2023.
What it is
A 2h43m deep dive by Flutter developer creativecreatorormaybenot into RenderObjects, the layer beneath widgets that handles layout and painting. It covers RenderBox, slivers, constraints and how to write custom render objects, with links to docs and example code.
What people said
Recommends hnnngwdlch · 2022-01 · Stack Overflow · on “Flutter chat text align like Whatsapp or Telegram”
Here's an example that you can run in DartPad that might be enough to get you started. It uses a SingleChildRenderObjectWidget for laying out the child and painting the ChatBubble 's chat message as well as the message time and a dummy check mark icon. To learn more about the RenderObject class I can recommend this video [this video] . It describes all relevant classes and methods in great depth and helped me a lot to create my first custom RenderObject . [LINK] import 'dart:ui' as ui; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:intl/intl.dart'; const Color darkBlue = Color.fromARGB(255, 18, 32, 47); void main() { runApp(MyApp()); } class MyApp
Recommends Wi Cheung · 2023-06 · Stack Overflow · on “How to implement TreeView with three-state CheckBoxes featuring select all and unselected all functionality”
Maybe you can create your own renderObject, I try my best for make the indent widget look like your image provided. Keep in mind this is not Sliver widget therefore this can cost some perform an issue. [LINK] also I suggest you take a look this video if youe interest about renderObject in flutter. [this video] main.dart import 'package:flutter/material.dart'; import 'indent_widget.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class My
Cites rickimaru · 2021-05 · Stack Overflow · on “Progressive Menu in Flutter (Hide Overflowing Elements in Dropdown)”
Maybe you can try creating a MultiChildRenderObjectWidget in which you can calculate the children size before painting. It's more complicated though because your like making a custom Row class. I created a sample but it may still contain bugs and need some improvements. Sample... threshold collapsible_menu_bar.dart import 'dart:math'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; class MenuBar extends StatelessWidget { MenuBar({ required this.onItemPressed, required this.children, this.minItemWidth = 110, this.minMoreItemsWidth = 70, Key? key, }) : super(key: key); final ValueChanged<int> onItemPressed; final List<M