Edited Answer
Updating answer as my original answer doesn’t actually cover the original context of the question.
You can use the prefixIcon in the TextField or in the TextFormField to get some widget as a leading in your TextField.
Example
TextField(
// ...,other fields
decoration: InputDecoration(
prefixIcon: prefixIcon??Icon(Icons.done),
),
),
PS: Do not get confuse between
prefixIconandprefixas this two
are different things.
https://api.flutter.dev/flutter/material/InputDecoration/prefix.html
Also if you want to achieve something like floating app bar then you can refer to my original answer.
Original answer
You can use my Flutter package to implement Floating AppBar in your application.
You need to add below package in your pub.
rounded_floating_app_bar: ^0.1.0
run $ flutter packages get from the command line.
Now in your Dart code, you can use:
import 'package:rounded_floating_app_bar/rounded_floating_app_bar.dart';
...
NestedScrollView(
headerSliverBuilder: (context, isInnerBoxScroll) {
return [
RoundedFloatingAppBar(
floating: true,
snap: true,
title: TextField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.search),
border: InputBorder.none,
),
),
),
];
},
body: Container(),
),
Output:
