DEV Community

Cover image for What’s New in Flutter 3.27.1: In-Depth Look with Code Examples
Sohanuzzaman Soad
Sohanuzzaman Soad

Posted on

What’s New in Flutter 3.27.1: In-Depth Look with Code Examples

Flutter 3.27.1 brings a host of new features, enhancements, and updates that improve both the developer experience and application performance. This version continues Flutter's mission of providing a seamless development experience across platforms while ensuring robust performance and modern UI capabilities. The improvements range from significant updates to Cupertino and Material Design widgets, better rendering engines for Android and iOS, to improved web performance with WebAssembly compatibility. Additionally, Flutter 3.27.1 introduces various framework and tooling enhancements that empower developers to build dynamic, accessible, and visually appealing applications with greater efficiency. Here’s a detailed exploration of the major changes, complete with code examples.

1. Cupertino Widget Enhancements

CupertinoCheckbox and CupertinoRadio

These widgets have been updated with new sizes, colors, stroke widths, and press behaviors. They now support mouse cursors, semantic labels, thumb images, and fill colors, making them more versatile and customizable.

Example:

CupertinoCheckbox(
  value: true,
  onChanged: (bool? newValue) {
    print('Checkbox clicked');
  },
  mouseCursor: SystemMouseCursors.click,
  semanticLabel: 'Enable notifications',
  fillColor: CupertinoColors.activeGreen,
)

CupertinoRadio<String>(
  value: 'option1',
  groupValue: selectedOption,
  onChanged: (String? newValue) {
    setState(() {
      selectedOption = newValue;
    });
  },
)
Enter fullscreen mode Exit fullscreen mode

CupertinoSlidingSegmentedControl

Visual and functional improvements include proportional layouts based on segment content, adjustments to thumb radius, separator height, and padding.

Example:

CupertinoSlidingSegmentedControl<int>(
  groupValue: selectedSegment,
  children: {
    0: Text('Home'),
    1: Text('Settings'),
  },
  onValueChanged: (int? newValue) {
    setState(() {
      selectedSegment = newValue;
    });
  },
)
Enter fullscreen mode Exit fullscreen mode

2. Material Design Updates

Component Theming

The introduction of new data classes such as CardThemeData, DialogThemeData, and TabBarThemeData allows for more consistent and customizable theming.

Example:

ThemeData(
  cardTheme: CardTheme(
    color: Colors.blueGrey,
    elevation: 4,
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(10),
    ),
  ),
  dialogTheme: DialogTheme(
    backgroundColor: Colors.white,
    titleTextStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
  ),
  tabBarTheme: TabBarTheme(
    labelColor: Colors.black,
    unselectedLabelColor: Colors.grey,
    indicator: BoxDecoration(
      color: Colors.blue,
      borderRadius: BorderRadius.circular(10),
    ),
  ),
)

Enter fullscreen mode Exit fullscreen mode

CarouselView.weighted

A new constructor allows for dynamic layouts within carousels by specifying relative weights for items.

Example:

CarouselView.weighted(
  itemWeights: [0.5, 0.3, 0.2],
  items: [
    Image.network('https://via.placeholder.com/150'),
    Image.network('https://via.placeholder.com/100'),
    Image.network('https://via.placeholder.com/50'),
  ],
)
Enter fullscreen mode Exit fullscreen mode

3. Framework Improvements

Row and Column Spacing

A new spacing parameter simplifies the application of fixed offsets between children.

Example:

Row(
  spacing: 10,
  children: [
    Icon(Icons.home),
    Icon(Icons.settings),
    Icon(Icons.notifications),
  ],
)

Column(
  spacing: 20,
  children: [
    Text('Hello'),
    Text('World'),
  ],
)

Enter fullscreen mode Exit fullscreen mode

Text Selection Enhancements

Support for Shift + Click gestures on desktop platforms has been added, along with improved behavior for text selection.

Example:

SelectableText(
  'This is a selectable text.',
  showCursor: true,
  cursorWidth: 2,
  onSelectionChanged: (TextSelection selection, SelectionChangedCause? cause) {
    print('Selection changed: $selection');
  },
)
Enter fullscreen mode Exit fullscreen mode

4. Engine Enhancements

Impeller on Android

Impeller is now the default rendering engine on modern Android devices, offering improved performance. Developers can revert to Skia if needed.

Example:

flutter:
  use-skia: true
Enter fullscreen mode Exit fullscreen mode

iOS Rendering

A new Metal rendering surface implementation reduces frame delays, particularly on high-frame-rate devices.

5. Web Platform Updates

WebAssembly Compatibility

Flutter plugins and packages are now compatible with WebAssembly, enhancing web performance.

Accessibility Improvements

Better support for headings, dialogs, and interactive elements.

Example:

Semantics(
  label: 'Submit button',
  child: ElevatedButton(
    onPressed: () {},
    child: Text('Submit'),
  ),
)
Enter fullscreen mode Exit fullscreen mode

6. Development Tools

DevTools Enhancements

New features include improved performance analysis and debugging capabilities.

Example:
Run the following command to start DevTools with the new options:

flutter pub global run devtools

7. Additional Resources and Repository Link

For more insights into Flutter 3.27.1, you can explore the official Flutter documentation, which provides in-depth explanations, migration guides, and best practices:

Flutter Documentation: Flutter 3.27 Release Notes

Additionally, visit the GitHub repository I created to see live examples of the new features in Flutter 3.27.1 It contains detailed code samples and project templates.

GitHub Repository: Flutter 3.27.1 Examples

Feel free to explore and contribute to the repository. Your feedback and pull requests are always welcome!

Conclusion

Flutter 3.27 reflects the framework’s continuous evolution, offering a robust toolset for building modern, performant applications. From Cupertino and Material design updates to powerful engine enhancements, this release is packed with features to make your Flutter development experience better than ever.

For more updates and projects, visit my GitHub profile: Sohanuzzaman Soad.

Top comments (1)

Collapse
 
tanjilulanwar profile image
Tanjilul Anwar

I like that it has web assembly support now