Skip to content

Same vs Different: The Lookup Table

This is your cheat sheet. The left column shows what you know from React; the right column shows the Flutter equivalent. Most entries map one-to-one; the ones that are genuinely different are called out with a note.

React conceptFlutter equivalentNotes
Function componentStatelessWidgetClass with build() method
Class componentStatefulWidget + State<T>Split into two classes
PropsConstructor parametersDart named params: MyWidget(name: 'Ava')
useStatesetState(() { ... })Lives in State<T> subclass
useEffect (mount)initState()Called once after first build
useEffect (unmount)dispose()Clean up controllers, streams, timers
useEffect (deps)Manual didUpdateWidget / RiverpodNo direct equivalent
useContext / ContextInheritedWidget / Provider packageProvider is the community standard
React.memoconst constructorDart const prevents rebuilds
key propKey / super.keySame purpose — tree reconciliation
JSXDart constructor calls<Text>Text('...')
CSS / StyleSheetWidget params + ThemeDataTextStyle, BoxDecoration, etc.
FlexboxRow / ColumnmainAxisAlignmentjustify-content
display: noneConditional with if or Visibilityif (show) MyWidget() in children list
react-router / Next.jsNavigator + routes / go_routerImperative or declarative routing
npm / package.jsonpub / pubspec.yamlflutter pub add package_name
Fast RefreshHot Reload (r in terminal)Preserves state; hot restart = full reload
.map() in JSX.map(...).toList() in childrenReturns List<Widget>
styled-componentsThemeData + widget paramsNo runtime CSS — all compile-time Dart
React.createContextInheritedWidget or ChangeNotifierProvider wraps both patterns
React
// React instinct — what you'd reach for
function ProfileCard({ name, isAdmin }) {
const [liked, setLiked] = useState(false);
return (
<div className="card" style={{ padding: 16, borderRadius: 12 }}>
<h3 style={{ margin: 0 }}>{name}</h3>
{isAdmin && <span className="badge">Admin</span>}
<button onClick={() => setLiked(l => !l)}>
{liked ? '❤️ Liked' : '🤍 Like'}
</button>
</div>
);
}
Flutter
// Flutter equivalent — layout is widgets
class ProfileCard extends StatefulWidget {
final String name;
final bool isAdmin;
const ProfileCard({super.key, required this.name, this.isAdmin = false});
@override
State<ProfileCard> createState() => _ProfileCardState();
}
class _ProfileCardState extends State<ProfileCard> {
bool _liked = false;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(widget.name,
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
if (widget.isAdmin)
Container(
margin: const EdgeInsets.only(top: 4),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: Colors.blue[100],
borderRadius: BorderRadius.circular(4),
),
child: const Text('Admin',
style: TextStyle(color: Colors.blue, fontSize: 12)),
),
const SizedBox(height: 8),
GestureDetector(
onTap: () => setState(() => _liked = !_liked),
child: Text(
_liked ? '❤️ Liked' : '🤍 Like',
style: const TextStyle(fontSize: 16),
),
),
],
),
);
}
}
What is the Flutter equivalent of npm / package.json?
In Flutter, how do you achieve the equivalent of CSS display: none to hide a widget conditionally?
React's Fast Refresh maps to which Flutter feature?
Why does Flutter split a stateful component into StatefulWidget + State<T>?