Total newbie here but I can't get around this. I want a reusable widget that takes a String title in its constructor and then uses it in the build's widget:
import 'package:flutter/material.dart';
class TemperatureInputDecoration extends StatelessWidget {
const TemperatureInputDecoration({Key? key, required this.title})
: super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return const InputDecorator(
decoration: InputDecoration(
labelText: title,
focusColor: Colors.orangeAccent,
),
);
}
}
I get an error on the line 'labelText: title' saying 'Invalid constant value'. I've tried widget.title, creating a getter for super.widget and using a Stateful widget but no go.
I've seen this page but none of it worked for me. Maybe it has something to do with InputDecoration not being a widget? Any help appreciated.