I've the below code working fine, and showing the FlatButton under the TextField:

import 'package:flutter/material.dart';

class LocationCapture extends StatelessWidget {
  LocationCapture(this.clickCallback, this.tc);
  final TextEditingController tc;
  final VoidCallback clickCallback;

  Widget build(BuildContext context) {
    return Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
      //    Row(
      //        children: <Widget>[
                TextField(controller: tc,),
                  child: const Icon(Icons.my_location),
                  onPressed: () => clickCallback(),
      //    ])

I tried adding Row to make them in single line, but it is not working, and showing blank screen!!


I was able to put them in line, by wrapping each element into a container, but still not happy for this as it require me to assign the container width, I need this to be done automatically:

    mainAxisAlignment: MainAxisAlignment.center,
    children: <Widget>[
          width: 180,
          child: TextField(
              controller: tc,
              enabled: false,
              textAlign: TextAlign.center,
              decoration: InputDecoration.collapsed(hintText: "")
          child: FlatButton(
                 child: const Icon(Icons.my_location),
                 onPressed: () => clickCallback(),

Solution 1: Dhrumil Shah - dhuma1981

This is how you can do it.

textDirection property of Row() widget will allow you to start the positioning of the children widget from the mentioned directions.

NOTE :- **You can remove or comment out the 'textDirection' if your are using MaterialApp() widget in your project. It takes care of the textDirection.

Expanded() widget is used to occupy the remaining whole space.

 child: Row(
            textDirection: TextDirection.rtl,
            children: <Widget>[
              FlatButton(onPressed: () {}, child: Text("Demo Button")),
              Expanded(child: TextFormField())