Getting Started
Get started with Forui in your Flutter project.
This guide assumes you have a basic understanding of Flutter and have already set up your development environment. If you're new to Flutter, you may follow the official installation guide.
Installation
From your Flutter project directory, run the following command to install Forui.
Forui 0.17.0+ requires Flutter 3.38.0+. Run flutter --version to check your Flutter version.
flutter pub add foruiUpgrading
Flutter does not automatically upgrade minor versions of packages prior to 1.0.0.
This means that that following entry in your pubspec.yaml file will not automatically upgrade to 0.17.0:
dependencies:
forui: ^0.16.0 // ❌ will not upgrade to 0.17.0To upgrade to the latest version of Forui, run the following command:
flutter pub upgrade forui --major-versionsFrom 0.17.0 onwards, Forui provides data driven fixes.
This means that you can automate some of the migration by running dart fix --apply.
Forui Icons
Forui Icons is bundled with the forui package. You don't need to install it separately if you install forui.
If you would like to only use the icons, run the following command from your Flutter project's directory.
flutter pub add forui_assetsUsage
To use Forui widgets in your Flutter app, import the Forui package and place the
FAnimatedTheme widget underneath
CupertinoApp, MaterialApp, or WidgetsApp at the root of the widget tree.
To generate a basic Forui app structure in your project, run:
dart run forui initOr copy & paste the following code snippet:
1import 'package:flutter/material.dart';23import 'package:forui/forui.dart';45void main() {6 runApp(const Application());7}89class Application extends StatelessWidget {10 const Application({super.key});1112 @override13 Widget build(BuildContext context) {14 /// Try changing this and hot reloading the application.15 ///16 /// To create a custom theme:17 /// ```shell18 /// dart forui theme create [theme template].19 /// ```20 final theme = FThemes.neutral.dark;2122 return MaterialApp(23 // TODO: replace with your application's supported locales.24 supportedLocales: FLocalizations.supportedLocales,25 // TODO: add your application's localizations delegates.26 localizationsDelegates: const [...FLocalizations.localizationsDelegates],27 // MaterialApp's theme is also animated by default with the same duration and curve.28 // See https://api.flutter.dev/flutter/material/MaterialApp/themeAnimationStyle.html for how to configure this.29 //30 // There is a known issue with implicitly animated widgets where their transition occurs AFTER the theme's.31 // See https://github.com/duobaseio/forui/issues/670.32 theme: theme.toApproximateMaterialTheme(),33 builder: (_, child) => FTheme(34 data: theme,35 child: FToaster(child: child!),36 ),37 // You can also replace FScaffold with Material Scaffold.38 home: const FScaffold(39 // TODO: replace with your widget.40 child: Example(),41 ),42 );43 }44}4546class Example extends StatefulWidget {47 const Example({super.key});4849 @override50 State<Example> createState() => _ExampleState();51}5253class _ExampleState extends State<Example> {54 int _count = 0;5556 @override57 Widget build(BuildContext context) => Center(58 child: Column(59 mainAxisSize: .min,60 spacing: 10,61 children: [62 Text('Count: $_count'),63 FButton(64 onPress: () => setState(() => _count++),65 suffix: const Icon(FIcons.chevronsUp),66 child: const Text('Increase'),67 ),68 ],69 ),70 );71}72It is perfectly fine to use Cupertino/Material widgets alongside Forui widgets!
1import 'package:flutter/cupertino.dart';23import 'package:forui/forui.dart';456void main() {7 runApp(const Application());8}910class Application extends StatelessWidget {11 const Application({super.key});1213 @override14 Widget build(BuildContext context) => CupertinoApp(15 builder: (context, child) =>16 FTheme(data: FThemes.neutral.light, child: child!),17 home: const FScaffold(child: Placeholder()),18 );19}20Themes
Forui provides a set of predefined themes that you can use out of the box.
In the example above, we used the FThemes.neutral.light theme, which is a light theme variant of the neutral color scheme.
Themes are a very powerful building block in Forui, allowing you to customize the look and feel of your app. To learn more about themes, refer to the Themes page.