Convert Figma logo to code with AI

flutter logosamples

A collection of Flutter examples and demos

17,049
7,486
17,049
49

Top Related Projects

164,677

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

An awesome list that curates the best Flutter libraries, tools, tutorials, articles and more.

[Example APPS] Basic Flutter apps, for flutter devs.

completely free for everyone. Its build-in Flutter Dart.

The repo contains the source code for all the tutorials on the FilledStacks Youtube channel.

11,778

A predictable state management library that helps implement the BLoC design pattern

Quick Overview

The flutter/samples repository is a collection of sample applications and code snippets for the Flutter framework. It serves as a resource for developers to learn Flutter best practices, explore various widgets and features, and find inspiration for their own projects. The repository is maintained by the Flutter team and community contributors.

Pros

  • Comprehensive collection of Flutter examples covering various use cases and features
  • Well-documented and regularly updated to reflect the latest Flutter best practices
  • Includes both simple examples and more complex, full-featured applications
  • Serves as a valuable learning resource for Flutter developers of all skill levels

Cons

  • Some examples may become outdated as Flutter evolves rapidly
  • Not all examples may follow the same coding style or structure
  • Some complex examples might be overwhelming for beginners
  • Limited coverage of certain advanced topics or niche use cases

Code Examples

Here are a few short code examples from the flutter/samples repository:

  1. Creating a simple animated list:
class AnimatedListSample extends StatefulWidget {
  @override
  _AnimatedListSampleState createState() => _AnimatedListSampleState();
}

class _AnimatedListSampleState extends State<AnimatedListSample> {
  final GlobalKey<AnimatedListState> _listKey = GlobalKey<AnimatedListState>();
  final List<String> _items = ['Item 1', 'Item 2', 'Item 3'];

  void _addItem() {
    final int index = _items.length;
    _items.add('Item ${index + 1}');
    _listKey.currentState!.insertItem(index);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Animated List')),
      body: AnimatedList(
        key: _listKey,
        initialItemCount: _items.length,
        itemBuilder: (context, index, animation) {
          return SlideTransition(
            position: animation.drive(Tween<Offset>(
              begin: const Offset(-1, 0),
              end: Offset.zero,
            )),
            child: ListTile(title: Text(_items[index])),
          );
        },
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _addItem,
        child: Icon(Icons.add),
      ),
    );
  }
}
  1. Implementing a custom painter:
class CirclePainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final paint = Paint()
      ..color = Colors.blue
      ..style = PaintingStyle.fill;
    canvas.drawCircle(Offset(size.width / 2, size.height / 2), 50, paint);
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) => false;
}

class CustomPainterExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Custom Painter')),
      body: Center(
        child: CustomPaint(
          painter: CirclePainter(),
          size: Size(200, 200),
        ),
      ),
    );
  }
}

Getting Started

To get started with the flutter/samples repository:

  1. Clone the repository:

    git clone https://github.com/flutter/samples.git
    
  2. Navigate to a specific sample directory:

    cd samples/name_of_sample
    
  3. Run the sample:

    flutter run
    

Make sure you have Flutter installed and set up on your development environment before running the samples.

Competitor Comparisons

164,677

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Pros of flutter

  • Comprehensive framework with core functionality and tools
  • Extensive documentation and API references
  • Larger community and more frequent updates

Cons of flutter

  • Larger repository size, potentially slower to clone and navigate
  • More complex codebase, steeper learning curve for contributors
  • May include experimental features or work-in-progress code

Code comparison

flutter:

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Flutter App')),
        body: Center(child: Text('Hello, World!')),
      ),
    );
  }
}

samples:

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Sample App')),
      body: Center(child: Text('Hello from Samples!')),
    );
  }
}

The samples repository focuses on providing specific examples and use cases, while flutter contains the core framework code. The samples code tends to be more concise and targeted towards demonstrating particular features or patterns.

An awesome list that curates the best Flutter libraries, tools, tutorials, articles and more.

Pros of awesome-flutter

  • Comprehensive collection of Flutter resources, including libraries, tools, and tutorials
  • Community-driven with frequent updates and contributions
  • Organized into categories for easy navigation and discovery

Cons of awesome-flutter

  • Lacks in-depth code examples and explanations
  • May include outdated or less maintained projects
  • No direct affiliation with the official Flutter team

Code comparison

While awesome-flutter doesn't provide direct code examples, samples offers practical implementations. Here's a brief comparison:

awesome-flutter (description of a package):

- [flutter_blurhash](https://github.com/moda20/flutter_blurhash) - Compact representation of a placeholder for an image by [@moda20](https://github.com/moda20).

samples (actual code example):

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Flutter Sample')),
      body: Center(child: Text('Hello, World!')),
    );
  }
}

awesome-flutter focuses on curating and listing resources, while samples provides hands-on code examples and complete projects for developers to learn from and experiment with. The choice between the two depends on whether you're looking for a comprehensive resource list or practical code implementations.

[Example APPS] Basic Flutter apps, for flutter devs.

Pros of FlutterExampleApps

  • More diverse range of app examples, covering a wider variety of use cases
  • Includes more complex and feature-rich applications
  • Regularly updated with new examples and improvements

Cons of FlutterExampleApps

  • Less official documentation and explanations for each example
  • May not always follow the most up-to-date Flutter best practices
  • Some examples might be outdated or not maintained as frequently

Code Comparison

FlutterExampleApps:

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

samples:

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;
  @override
  Widget build(BuildContext context) {
    // Build method implementation
  }
}

The code comparison shows that FlutterExampleApps uses a StatefulWidget for the home page, while samples uses a StatelessWidget. The samples repository also uses null safety and the required keyword, indicating more recent Flutter practices.

Both repositories offer valuable resources for Flutter developers, with samples providing more official and standardized examples, while FlutterExampleApps offers a broader range of app ideas and implementations.

completely free for everyone. Its build-in Flutter Dart.

Pros of Best-Flutter-UI-Templates

  • Focuses on visually appealing and modern UI designs
  • Provides ready-to-use templates for common app scenarios
  • Includes more complex and feature-rich examples

Cons of Best-Flutter-UI-Templates

  • Less official documentation and maintenance compared to samples
  • May not cover as wide a range of Flutter features and concepts
  • Could be overwhelming for beginners due to complex implementations

Code Comparison

Best-Flutter-UI-Templates (Hotel Booking):

class HotelListView extends StatelessWidget {
  const HotelListView({
    Key? key,
    this.hotelData,
    this.animationController,
    this.animation,
    this.callback,
  }) : super(key: key);
  // ... (more complex widget implementation)
}

samples (Navigation and Routing):

class BookRouteInformationParser extends RouteInformationParser<BookRoutePath> {
  @override
  Future<BookRoutePath> parseRouteInformation(
      RouteInformation routeInformation) async {
    final uri = Uri.parse(routeInformation.location!);
    // ... (simpler implementation focused on concepts)
  }
}

Best-Flutter-UI-Templates offers more polished, production-ready UI examples, while samples provides a broader range of Flutter concepts with simpler implementations. samples is better for learning core Flutter principles, while Best-Flutter-UI-Templates is ideal for developers seeking inspiration for attractive app designs.

The repo contains the source code for all the tutorials on the FilledStacks Youtube channel.

Pros of flutter-tutorials

  • More focused on real-world application development and best practices
  • Includes video tutorials alongside code examples for better learning experience
  • Covers a wider range of topics, including state management and architecture patterns

Cons of flutter-tutorials

  • Less official and may not always align with Flutter's recommended practices
  • Fewer examples compared to samples repository
  • May not be as frequently updated as the official samples

Code Comparison

samples:

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Flutter Sample')),
      body: Center(child: Text('Hello, World!')),
    );
  }
}

flutter-tutorials:

class HomeView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ViewModelBuilder<HomeViewModel>.reactive(
      viewModelBuilder: () => HomeViewModel(),
      builder: (context, model, child) => Scaffold(
        body: Center(child: Text(model.title)),
      ),
    );
  }
}

The samples code showcases a basic Flutter widget structure, while flutter-tutorials demonstrates a more advanced architecture using a ViewModel pattern for separation of concerns.

11,778

A predictable state management library that helps implement the BLoC design pattern

Pros of bloc

  • Focused on state management, providing a more specialized solution
  • Extensive documentation and tutorials for learning the BLoC pattern
  • Active community with frequent updates and contributions

Cons of bloc

  • Steeper learning curve for developers new to reactive programming
  • May introduce unnecessary complexity for simpler applications
  • Limited to BLoC pattern, while samples offers a variety of approaches

Code Comparison

bloc example:

class CounterBloc extends Bloc<CounterEvent, int> {
  CounterBloc() : super(0) {
    on<Increment>((event, emit) => emit(state + 1));
    on<Decrement>((event, emit) => emit(state - 1));
  }
}

samples example:

class CounterModel extends ChangeNotifier {
  int _count = 0;
  int get count => _count;

  void increment() {
    _count++;
    notifyListeners();
  }
}

Summary

bloc focuses on state management using the BLoC pattern, offering a robust solution for complex applications. It provides extensive documentation and community support but may have a steeper learning curve.

samples, on the other hand, offers a broader range of examples covering various Flutter concepts and patterns. It's more suitable for beginners and provides flexibility in choosing different state management approaches.

The code comparison illustrates the difference in complexity and approach between the two repositories, with bloc using a more reactive programming style and samples demonstrating a simpler, more traditional approach.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Flutter samples

Build Status

A collection of open source samples that illustrate best practices for Flutter.

Visual samples index

The easiest way to browse through the samples in this repo (as well as a few others!) is the visual samples index.

Tip: minimize download size

As this repository is quite big, you can use svn to download a single example. For example:

svn co https://github.com/flutter/samples/trunk/provider_shopper

You can also use a partial clone to skip blob objects that aren't currently checked out, while including the full commit history:

git clone --filter=blob:none https://github.com/flutter/samples.git

Interested in contributing?

See the contributor's guide!

Questions or issues?

If you have a general question about one of these samples or how to adapt its techniques for one of your own apps, try one of these resources:

If you run into a bug in one of the samples, please file an issue in the flutter/samples issue tracker.